1+ REM Disable "!Foo!" expansions because they break the filter syntax
2+ setlocal disableextensions
3+
14set target = %1
25set sdkVersion = %2
36set runtimeVersion = %3
@@ -18,12 +21,35 @@ set HELIX=%helixQueue%
1821
1922%DOTNET_ROOT% \dotnet vstest %target% -lt > discovered.txt
2023find /c " Exception thrown" discovered.txt
21- if %errorlevel% equ 0 (
22- echo Exception thrown during test discovery.
23- type discovered.txt
24+ REM "ERRORLEVEL is not %ERRORLEVEL%" https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743/
25+ if not errorlevel 1 (
26+ echo Exception thrown during test discovery. 1 >& 2
27+ type discovered.txt 1 >& 2
2428 exit 1
2529)
2630
27- %DOTNET_ROOT% \dotnet vstest %target% --logger:trx --logger:console;verbosity=normal
31+ set exit_code = 0
32+
33+ REM Run non-flaky tests first
34+ REM We need to specify all possible Flaky filters that apply to this environment, because the flaky attribute
35+ REM only puts the explicit filter traits the user provided in
36+ REM Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md
37+ set NONFLAKY_FILTER = " Flaky:All!=true&Flaky:Helix:All ! =true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue: %HELIX% ! =true"
38+ echo Running non-flaky tests.
39+ %DOTNET_ROOT% \dotnet vstest %target% --logger:trx --logger:console;verbosity=normal --TestCaseFilter:%NONFLAKY_FILTER%
40+ if errorlevel 1 (
41+ echo Failure in non-flaky test 1 >& 2
42+ set exit_code = 1
43+ REM DO NOT EXIT
44+ )
45+
46+ set FLAKY_FILTER = " Flaky:All=true|Flaky:Helix:All=true|Flaky:Helix:Queue:All=true|Flaky:Helix:Queue:%HELIX% =true"
47+ echo Running known-flaky tests.
48+ %DOTNET_ROOT% \dotnet vstest %target% --logger:trx --logger:console;verbosity=normal --TestCaseFilter:%FLAKY_FILTER%
49+ if errorlevel 1 (
50+ echo Failure in flaky test 1 >& 2
51+ REM DO NOT EXIT and DO NOT SET EXIT_CODE to 1
52+ )
2853
54+ exit %exit_code%
2955
0 commit comments