forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruncitests.cmd
More file actions
318 lines (253 loc) · 11.3 KB
/
runcitests.cmd
File metadata and controls
318 lines (253 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
::-------------------------------------------------------------------------------------------------------
:: Copyright (C) Microsoft. All rights reserved.
:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
::-------------------------------------------------------------------------------------------------------
:: ============================================================================
::
:: runcitests.cmd
::
:: Runs tests for continuous integration. This script is called from the VSO
:: build and it runs all tests for x86 and x64, debug and test build configs.
:: Logs are copied to build drop.
::
:: Do not use this script to run all tests on your dev box.
:: - It will delete all your existing test logs
:: - It does not run the various flavors of the tests in parallel (though
:: this is not currently possible anyway because rl stages logs in a
:: common directory)
:: - It does nothing to provide useful output when there are failures, e.g.
:: they can be buried under thousands of lines of output from further
:: tests run.
:: - It cannot be cancelled without risk of polluting your command prompt
:: environment with environment variables that will make further calls to
:: runtests.cmd behave unexpectedly.
:: - It will copy the logs to a folder named \testlogs in the directory you
:: started this script from.
::
:: ============================================================================
@echo off
setlocal
if "%TF_BUILD_BINARIESDIRECTORY%" == "" (
echo TF_BUILD_BINARIESDIRECTORY is required for this script to work correctly.
exit /b 1
)
set _RootDir=%~dp0..
set _StagingDir=%TF_BUILD_BINARIESDIRECTORY%
REM %TF_BUILD_DROPLOCATION% is not required -- used only for an informational message
set _DropRootDir=%TF_BUILD_DROPLOCATION%
set _HadFailures=0
:: ============================================================================
:: Main script
:: ============================================================================
:main
call :parseArgs %*
if not "%fShowUsage%" == "" (
call :printUsage
goto :eof
)
call :validateArgs
if not "%fShowGetHelp%" == "" (
call :printGetHelp
goto :eof
)
if not "%TF_BUILD%" == "True" (
echo Error: TF_BUILD environment variable is not set to "True".
echo This script must be run under a TF Build Agent environment.
exit /b 2
)
:: Cannot run tests for arm on build machine and release builds
:: do not work with ch.exe so no-op those configurations.
:: Include _RunAll in the check because if it is specified it
:: should trump this early out.
if "%_RunAll%%_BuildArch%" == "arm" goto :noTests
if "%_RunAll%%_BuildArch%" == "arm64" goto :noTests
if "%_RunAll%%_BuildType%" == "release" goto :noTests
pushd %_RootDir%\test
set _TestDir=%CD%
call :doSilent rd /s/q %_TestDir%\logs
if not "%_RunAll%" == "" (
call :runTests x86 debug
call :runTests x86 test
call :runTests x64 debug
call :runTests x64 test
call :runNativeTests x86 debug
call :runNativeTests x86 test
call :runNativeTests x64 debug
call :runNativeTests x64 test
call :summarizeLogs summary.log
) else (
call :runTests %_BuildArch% %_BuildType% %_ExtraArgs%
call :runNativeTests %_BuildArch% %_BuildType%
call :summarizeLogs summary.%_BuildArch%%_BuildType%.log
)
call :copyLogsToDrop
echo.
echo -- runcitests.cmd ^>^> Failure code: %_HadFailures%
if "%_HadFailures%" NEQ "0" (
if "%_HadFailures%" == "3" (
echo -- runcitests.cmd ^>^> Unit tests failed! 1>&2
) else if "%_HadFailures%" == "4" (
echo -- runcitests.cmd ^>^> Native tests failed! 1>&2
) else (
echo -- runcitests.cmd ^>^> Unknown failure! 1>&2
)
) else (
echo -- runcitests.cmd ^>^> Tests passed!
)
echo -- runcitests.cmd ^>^> Logs at %_DropRootDir%\testlogs
popd
exit /b %_HadFailures%
:noTests
echo -- runcitests.cmd ^>^> The tests are not supported on this build configuration.
echo -- runcitests.cmd ^>^> No tests were run. This is expected.
echo -- runcitests.cmd ^>^> Configuration: %_BuildArch% %_BuildType%
exit /b 0
:: ============================================================================
:: Run one test suite against one build config and record if there were errors
:: ============================================================================
:runTests
:: save the architecture and build values, then obtain the rest of the arguments
set arch=%1
set build=%2
shift
shift
set rest=
:rest_loop
if "%1"=="" goto after_rest_loop
set rest=%rest% %1
shift
goto rest_loop
:after_rest_loop
call :do %_TestDir%\runtests.cmd -%arch%%build% %rest% -quiet -cleanupall -binDir %_StagingDir%\bin
if "%_error%" NEQ "0" (
echo -- runcitests.cmd ^>^> runtests.cmd failed
set _HadFailures=3
)
goto :eof
:: ============================================================================
:: Run jsrt test suite against one build config and record if there were errors
:: ============================================================================
:runNativeTests
echo -- runcitests.cmd ^>^> Running native tests... this can take some time
if not exist %_LogDir%\ mkdir %_LogDir%
set _LogFile=%_TestDir%\logs\%1_%2\nativetests.log
call :do %_TestDir%\runnativetests.cmd -%1%2 -d yes > %_LogFile% 2>&1
echo -- runcitests.cmd ^>^> Running native tests... DONE!
if "%_error%" NEQ "0" (
echo -- runcitests.cmd ^>^> runnativetests.cmd failed; printing %_LogFile%
powershell "if (Test-Path %_LogFile%) { Get-Content %_LogFile% }"
set _HadFailures=4
)
goto :eof
:: ============================================================================
:: Copy all result logs to the drop share
:: ============================================================================
:copyLogsToDrop
:: /S Copy all non-empty dirs
:: /Y Do not prompt for overwriting destination files
:: /C Continue copying if there are errors
:: /I Assume destination is a directory if it does not exist
call :do xcopy %_TestDir%\logs %_StagingDir%\testlogs /S /Y /C /I
goto :eof
:: ============================================================================
:: Summarize the logs into a listing of only the failures
:: ============================================================================
:summarizeLogs
pushd %_TestDir%\logs
findstr /sp failed rl.results.log > %1
findstr /sip failed nativetests.log >> %1
rem Echo to stderr so that VSO includes the output in the build summary
type %1 1>&2
popd
goto :eof
:: ============================================================================
:: Print usage
:: ============================================================================
:printUsage
echo runcitests.cmd -x86^|-x64^|-arm -debug^|-test^|-release
echo.
echo Runs tests post-build for automated VSO TFS Builds.
echo Depends on TFS Build environment.
echo.
echo Required switches:
echo.
echo Specify architecture of build to test:
echo.
echo -x86 Build arch of binaries is x86
echo -x64 Build arch of binaries is x64
echo -arm Build arch of binaries is ARM
echo.
echo Specify type of of build to test:
echo.
echo -debug Build type of binaries is debug
echo -test Build type of binaries is test
echo -release Build type of binaries is release
echo.
echo Shorthand combinations can be used, e.g. -x64debug
echo.
echo Note: No tests are run for ARM or release as they are
echo not supported. The switches are provided for tooling
echo convenience.
goto :eof
:: ============================================================================
:: Print how to get help
:: ============================================================================
:printGetHelp
echo For help use runcitests.cmd -?
goto :eof
:: ============================================================================
:: Parse the user arguments into environment variables
:: ============================================================================
:parseArgs
:NextArgument
if "%1" == "-?" set fShowUsage=1& goto :ArgOk
if "%1" == "/?" set fShowUsage=1& goto :ArgOk
if /i "%1" == "-x86" set _BuildArch=x86& goto :ArgOk
if /i "%1" == "-x64" set _BuildArch=x64& goto :ArgOk
if /i "%1" == "-arm" set _BuildArch=arm& goto :ArgOk
if /i "%1" == "-debug" set _BuildType=debug& goto :ArgOk
if /i "%1" == "-test" set _BuildType=test& goto :ArgOk
if /i "%1" == "-release" set _BuildType=release& goto :ArgOk
if /i "%1" == "-x86debug" set _BuildArch=x86&set _BuildType=debug& goto :ArgOk
if /i "%1" == "-x64debug" set _BuildArch=x64&set _BuildType=debug& goto :ArgOk
if /i "%1" == "-armdebug" set _BuildArch=arm&set _BuildType=debug& goto :ArgOk
if /i "%1" == "-x86test" set _BuildArch=x86&set _BuildType=test& goto :ArgOk
if /i "%1" == "-x64test" set _BuildArch=x64&set _BuildType=test& goto :ArgOk
if /i "%1" == "-armtest" set _BuildArch=arm&set _BuildType=test& goto :ArgOk
if /i "%1" == "-x86release" set _BuildArch=x86&set _BuildType=release& goto :ArgOk
if /i "%1" == "-x64release" set _BuildArch=x64&set _BuildType=release& goto :ArgOk
if /i "%1" == "-armrelease" set _BuildArch=arm&set _BuildType=release& goto :ArgOk
if /i "%1" == "-all" set _RunAll=1& goto :ArgOk
if not "%1" == "" set _ExtraArgs=%_ExtraArgs% %1& goto :ArgOk
goto :eof
:ArgOk
shift
goto :NextArgument
:: ============================================================================
:: Validate arguments; if non specified default to -all
:: ============================================================================
:validateArgs
if "%_BuildArch%" == "" (
set _RunAll=1
)
if "%_BuildType%" == "" (
set _RunAll=1
)
goto :eof
:: ============================================================================
:: Echo a command line before executing it
:: ============================================================================
:do
echo -- runcitests.cmd ^>^> %*
cmd /s /c "%*"
set _error=%ERRORLEVEL%
goto :eof
:: ============================================================================
:: Echo a command line before executing it and redirect the command's output
:: to nul
:: ============================================================================
:doSilent
echo -- runcitests.cmd ^>^> %* ^> nul 2^>^&1
cmd /s /c "%* > nul 2>&1"
set _error=%ERRORLEVEL%
goto :eof