Skip to content

Commit fa1604a

Browse files
authored
Make HttpStress fail on unobserved exceptions (#115849)
There were no unobserved exceptions in recent HttpStress runs, so it should be OK (and desired) to fail the test run if we detect one.
1 parent 915f129 commit fa1604a

File tree

1 file changed

+9
-1
lines changed
  • src/libraries/System.Net.Http/tests/StressTests/HttpStress

1 file changed

+9
-1
lines changed

src/libraries/System.Net.Http/tests/StressTests/HttpStress/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,20 @@ private static async Task<ExitCode> Run(Configuration config)
244244
}
245245

246246
// return nonzero status code if there are stress errors
247-
return client?.TotalErrorCount == 0 ? ExitCode.Success : ExitCode.StressError;
247+
return client?.TotalErrorCount == 0 && s_unobservedExceptions.Count == 0 ? ExitCode.Success : ExitCode.StressError;
248248
}
249249

250250
private static void PrintUnobservedExceptions()
251251
{
252+
if (s_unobservedExceptions.Count == 0)
253+
{
254+
Console.WriteLine("No unobserved exceptions detected.");
255+
return;
256+
}
257+
258+
Console.ForegroundColor = ConsoleColor.DarkRed;
252259
Console.WriteLine($"Detected {s_unobservedExceptions.Count} unobserved exceptions:");
260+
Console.ResetColor();
253261

254262
int i = 1;
255263
foreach (KeyValuePair<string, int> kv in s_unobservedExceptions.OrderByDescending(p => p.Value))

0 commit comments

Comments
 (0)