From e70ffaa1fb40540722cfd557468e6dfb612097f2 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 5 Jun 2022 08:15:46 -0400 Subject: [PATCH] Fix regex outerloop tests (#70246) --- .../tests/FunctionalTests/Regex.Match.Tests.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index e51736ddfa26d1..1cb13ae2ef21f7 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -1025,7 +1025,15 @@ public async Task Match_VaryingLengthStrings(RegexEngine engine, RegexOptions op [MemberData(nameof(RegexHelpers.AvailableEngines_MemberData), MemberType = typeof(RegexHelpers))] public async Task Match_VaryingLengthStrings_Huge(RegexEngine engine) { - await Match_VaryingLengthStrings(engine, RegexOptions.None, 100_000); + RegexHelpers.SetSafeSizeThreshold(100_002); + try + { + await Match_VaryingLengthStrings(engine, RegexOptions.None, 100_000); + } + finally + { + RegexHelpers.RestoreSafeSizeThresholdToDefault(); + } } public static IEnumerable Match_DeepNesting_MemberData() @@ -1923,7 +1931,7 @@ public async Task StressTestDeepNestingOfConcat(RegexEngine engine, string patte string fullpattern = string.Concat(string.Concat(Enumerable.Repeat($"({pattern}", pattern_repetition).Concat(Enumerable.Repeat(")", pattern_repetition))), anchor); string fullinput = string.Concat(Enumerable.Repeat(input, input_repetition)); - RegexHelpers.SetSafeSizeThreshold(10_000); + RegexHelpers.SetSafeSizeThreshold(10_005); Regex re; try { @@ -1955,7 +1963,7 @@ public async Task StressTestDeepNestingOfLoops(RegexEngine engine, string begin, string fullpattern = string.Concat(Enumerable.Repeat(begin, pattern_repetition)) + inner + string.Concat(Enumerable.Repeat(end, pattern_repetition)); string fullinput = string.Concat(Enumerable.Repeat(input, input_repetition)); - RegexHelpers.SetSafeSizeThreshold(10_000); + RegexHelpers.SetSafeSizeThreshold(int.MaxValue); Regex re; try {