Skip to content

Commit 5aef85a

Browse files
authored
Fix regex test OOM (#47209)
1 parent 9e9c76a commit 5aef85a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libraries/System.Text.RegularExpressions/tests/Regex.Match.Tests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,9 @@ public void Match_DefaultTimeout_Throws(RegexOptions options)
557557
}
558558

559559
// On 32-bit we can't test these high inputs as they cause OutOfMemoryExceptions.
560+
// On Linux, we may get killed by the OOM Killer; on Windows, it will swap instead
560561
[OuterLoop("Can take several seconds")]
561-
[ConditionalTheory(typeof(Environment), nameof(Environment.Is64BitProcess))]
562+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess), nameof(PlatformDetection.IsWindows))]
562563
[InlineData(@"a\s+", RegexOptions.None)]
563564
[InlineData(@"a\s+", RegexOptions.Compiled)]
564565
[InlineData(@"a\s+ ", RegexOptions.None)]
@@ -571,8 +572,9 @@ public void Match_Timeout_Loop_Throws(string pattern, RegexOptions options)
571572
}
572573

573574
// On 32-bit we can't test these high inputs as they cause OutOfMemoryExceptions.
575+
// On Linux, we may get killed by the OOM Killer; on Windows, it will swap instead
574576
[OuterLoop("Can take several seconds")]
575-
[ConditionalTheory(typeof(Environment), nameof(Environment.Is64BitProcess))]
577+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess), nameof(PlatformDetection.IsWindows))]
576578
[InlineData(RegexOptions.None)]
577579
[InlineData(RegexOptions.Compiled)]
578580
public void Match_Timeout_Repetition_Throws(RegexOptions options)

0 commit comments

Comments
 (0)