-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_all_unit_tests.cmd
More file actions
209 lines (178 loc) · 4.56 KB
/
Copy pathrun_all_unit_tests.cmd
File metadata and controls
209 lines (178 loc) · 4.56 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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
SET ScriptPath=%~n0[%~x0]
SET ScriptDir=%~dp0
IF DEFINED SIS_CMAKE_BUILD_DIR (
SET CMakeDir=%SIS_CMAKE_BUILD_DIR%
) ELSE (
SET CMakeDir=%ScriptDir%_build
)
SET ListOnly=0
SET RunMake=1
SET UnitOnly=0
SET ComponentOnly=0
SET TestVerbosityDefault=3
SET TestVerbosity=%TEST_VERBOSITY%
IF NOT DEFINED TestVerbosity SET TestVerbosity=%TestVerbosityDefault%
IF DEFINED XTESTS_VERBOSITY SET TestVerbosity=%XTESTS_VERBOSITY%
SET BuildConfig=Release
IF DEFINED CMAKE_BUILD_TYPE SET BuildConfig=%CMAKE_BUILD_TYPE%
:: #########################################################
:: command-line handling
:parse_args
IF "%~1"=="" GOTO args_done
IF /I "%~1"=="--help" GOTO show_help
IF /I "%~1"=="-l" (
SET ListOnly=1
GOTO next_arg
)
IF /I "%~1"=="--list-only" (
SET ListOnly=1
GOTO next_arg
)
IF /I "%~1"=="-M" (
SET RunMake=0
GOTO next_arg
)
IF /I "%~1"=="--no-make" (
SET RunMake=0
GOTO next_arg
)
IF /I "%~1"=="--unit-only" (
SET UnitOnly=1
GOTO next_arg
)
IF /I "%~1"=="--component-only" (
SET ComponentOnly=1
GOTO next_arg
)
IF /I "%~1"=="--verbosity" (
SHIFT
IF "%~1"=="" (
ECHO %ScriptPath%: --verbosity requires an argument 1>&2
EXIT /B 1
)
SET TestVerbosity=%~1
GOTO next_arg
)
ECHO %ScriptPath%: unrecognised argument '%~1'; use --help for usage 1>&2
EXIT /B 1
:next_arg
SHIFT
GOTO parse_args
:args_done
IF %UnitOnly% NEQ 0 IF %ComponentOnly% NEQ 0 (
ECHO %ScriptPath%: --unit-only and --component-only are mutually exclusive 1>&2
EXIT /B 1
)
IF %UnitOnly% NEQ 0 (
SET TestKindDescription=unit test
SET FindPattern=test[._]unit[._].*\.exe$
) ELSE IF %ComponentOnly% NEQ 0 (
SET TestKindDescription=component test
SET FindPattern=test[._]component[._].*\.exe$
) ELSE (
SET TestKindDescription=component and unit test
SET FindPattern=test[._]unit[._].*\.exe$ test[._]component[._].*\.exe$
)
:: #########################################################
:: main()
SET status=0
IF %RunMake% NEQ 0 (
IF %ListOnly% EQU 0 (
ECHO Executing build and then running all !TestKindDescription! programs
CALL :do_build
IF ERRORLEVEL 1 SET status=1
)
) ELSE (
IF NOT EXIST "%CMakeDir%\CMakeCache.txt" (
ECHO %ScriptPath%: cannot run in '--no-make' mode without a previous successful build step 1>&2
EXIT /B 1
)
)
IF %status% EQU 0 (
IF %ListOnly% NEQ 0 (
ECHO Listing all !TestKindDescription! programs
) ELSE (
ECHO Running all !TestKindDescription! programs
)
FOR /F "usebackq delims=" %%f IN (`DIR /A:-D /B /S "%CMakeDir%" 2^>NUL ^| FINDSTR /I /R "%FindPattern%"`) DO (
IF !ListOnly! NEQ 0 (
ECHO would execute %%f:
) ELSE (
ECHO.
ECHO executing %%f:
CALL "%%f" --verbosity=!TestVerbosity!
IF ERRORLEVEL 1 (
SET status=1
GOTO tests_done
)
)
)
)
:tests_done
IF !status! NEQ 0 (
ENDLOCAL
EXIT /B 1
)
ENDLOCAL
EXIT /B 0
:: #########################################################
:: helpers
:do_build
IF DEFINED SIS_CMAKE_MAKE_COMMAND (
PUSHd "%CMakeDir%"
CALL %SIS_CMAKE_MAKE_COMMAND%
SET build_status=!ERRORLEVEL!
POPD
EXIT /B !build_status!
)
IF EXIST "%CMakeDir%\Makefile" (
PUSHd "%CMakeDir%"
IF DEFINED MSYSTEM (
mingw32-make.exe
) ELSE (
make
)
SET build_status=!ERRORLEVEL!
POPD
EXIT /B !build_status!
)
cmake --build "%CMakeDir%" --config %BuildConfig%
EXIT /B %ERRORLEVEL%
:show_help
IF EXIST "%ScriptDir%.sis\script_info_lines.txt" (
type "%ScriptDir%.sis\script_info_lines.txt"
)
ECHO.
ECHO Runs all (matching) unit-test and/or component-test programs
ECHO.
ECHO %ScriptPath% [ ... flags/options ... ]
ECHO.
ECHO Flags/options:
ECHO.
ECHO behaviour:
ECHO.
ECHO -l
ECHO --list-only
ECHO lists the target programs but does not execute them
ECHO.
ECHO -M
ECHO --no-make
ECHO does not execute CMake and make before running tests
ECHO.
ECHO --unit-only
ECHO runs only unit-test programs (test.unit.* / test_unit*)
ECHO.
ECHO --component-only
ECHO runs only component-test programs (test.component.* / test_component*)
ECHO.
ECHO --verbosity ^<verbosity^>
ECHO specifies an explicit verbosity for the unit-test(s)
ECHO.
ECHO standard flags:
ECHO.
ECHO --help
ECHO displays this help and terminates
EXIT /B 0
:: ############################# end of file ############################ ::