Skip to content

Commit dc9a09a

Browse files
Fix libraries Windows test runner script (#88354)
Having HAS_TEST_RESULTS unset leads to a Windows CMD script syntax error. Clean up a few other things while there: 1. Explicitly set ENABLEEXTENSIONS 2. Set a variable to the test exit code. There's an unsafe assumption currently that `%ERRORLEVEL%` doesn't change between the test run and all of the subsequent uses. 3. Remove unnecessary quotes around setting `HAS_TEST_RESULTS=1` Fixes #88353
1 parent cd26e63 commit dc9a09a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

eng/testing/RunnerTemplate.cmd

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@echo off
2-
setlocal enabledelayedexpansion
2+
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
33

44
set EXECUTION_DIR=%~dp0
55

@@ -44,6 +44,9 @@ set EXECUTION_DIR=%~dp0
4444
:: Don't use a globally installed SDK.
4545
set DOTNET_MULTILEVEL_LOOKUP=0
4646

47+
:: Assume failure
48+
set HAS_TEST_RESULTS=0
49+
4750
:: ========================= BEGIN Test Execution =============================
4851
echo ----- start %DATE% %TIME% =============== To repro directly: =====================================================
4952
echo pushd %EXECUTION_DIR%
@@ -53,22 +56,23 @@ echo ===========================================================================
5356
pushd %EXECUTION_DIR%
5457
@echo on
5558
[[RunCommands]]
59+
@set _exit_code=%ERRORLEVEL%
5660
@echo off
5761
if exist testResults.xml (
58-
set "HAS_TEST_RESULTS=1"
62+
set HAS_TEST_RESULTS=1
5963
)
6064
popd
61-
echo ----- end %DATE% %TIME% ----- exit code %ERRORLEVEL% ----------------------------------------------------------
65+
echo ----- end %DATE% %TIME% ----- exit code %_exit_code% ----------------------------------------------------------
6266
:: The helix work item should not exit with non-zero if tests ran and produced results
6367
:: The special console runner for runtime returns 1 when tests fail
64-
if %ERRORLEVEL%==1 (
68+
if %_exit_code%==1 (
6569
if %HAS_TEST_RESULTS%==1 (
6670
if not "%HELIX_WORKITEM_PAYLOAD%"=="" (
6771
exit /b 0
6872
)
6973
)
7074
)
71-
exit /b %ERRORLEVEL%
75+
exit /b %_exit_code%
7276
:: ========================= END Test Execution =================================
7377

7478
:usage

0 commit comments

Comments
 (0)