Skip to content

Commit 781b35d

Browse files
authored
Adding argument parsing to script to enable --track argument to CTest (#428)
1 parent 5d44f33 commit 781b35d

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

BuildAndTest.bat.in

+33-15
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,31 @@
22

33
SET BUILD_TYPE=Release
44

5-
REM Skip build step if continuous or individual mode
5+
REM Parse arguments
6+
SET COMMAND=%0
7+
SET TEST_MODE=%1
8+
SHIFT
9+
10+
:loop
11+
IF NOT "%1"=="" (
12+
IF "%1"=="--test" (
13+
SET INDIVIDUAL_TEST=%2
14+
SHIFT
15+
)
16+
IF "%1"=="--track" (
17+
SET TEST_TRACK=--track %2
18+
SHIFT
19+
)
20+
SHIFT
21+
GOTO :loop
22+
)
623

24+
REM Skip build step if continuous or individual mode
725
REM Skip clean build step if not nightly mode
8-
if "%1" == "-C" goto cleansuccess
9-
if "%1" == "-I" goto cleansuccess
10-
if "%1" == "" goto cleansuccess
11-
if "%1" == "-E" goto cleansuccess
26+
if "%TEST_MODE%" == "-C" goto cleansuccess
27+
if "%TEST_MODE%" == "-I" goto cleansuccess
28+
if "%TEST_MODE%" == "" goto cleansuccess
29+
if "%TEST_MODE%" == "-E" goto cleansuccess
1230

1331
ECHO Clean...
1432
"${CMAKE_MAKE_PROGRAM}" ALL_BUILD.vcxproj /p:Configuration=Release /target:clean
@@ -17,33 +35,33 @@ IF ERRORLEVEL 1 GOTO buildfail
1735
:cleansuccess
1836

1937
rem ---------------------------------------
20-
if "%1" == "" goto experimental
21-
if "%1" == "-E" goto experimental
22-
if "%1" == "-N" goto nightly
23-
if "%1" == "-C" goto continuous
24-
if "%1" == "-I" goto individual
38+
if "%TEST_MODE%" == "" goto experimental
39+
if "%TEST_MODE%" == "-E" goto experimental
40+
if "%TEST_MODE%" == "-N" goto nightly
41+
if "%TEST_MODE%" == "-C" goto continuous
42+
if "%TEST_MODE%" == "-I" goto individual
2543

2644
:experimental
27-
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Experimental --output-on-failure
45+
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Experimental --output-on-failure %TEST_TRACK%
2846
goto success
2947

3048
:nightly
3149
@REM Clean before the nightly build to enforce all build warnings appear on all nightly dashboard submissions
32-
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Nightly
50+
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Nightly %TEST_TRACK%
3351
goto success
3452

3553
:continuous
36-
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Continuous
54+
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Continuous %TEST_TRACK%
3755
@REM Wait for some time before continue to allow checking the results of the executions
3856
timeout /t 15
3957
goto success
4058

4159
:individual
4260
@REM Run individual tests with regexp search
4361
@REM Display the list of tests
44-
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%2" -N
62+
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%INDIVIDUAL_TEST%" -N %TEST_TRACK%
4563
@REM Run selected tests
46-
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%2" -V
64+
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%INDIVIDUAL_TEST%" -V %TEST_TRACK%
4765
goto success
4866

4967
:success

BuildAndTest.sh.in

+24-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
ORIGPATH=$PATH
44
DIRCMD=0
55

6-
# Prevent X server related test errors (vtkXOpenGLRenderWindow: bad X server connection)
7-
export DISPLAY=:0
8-
96
finish()
107
{
118
PATH=$ORIGPATH
@@ -18,7 +15,27 @@ buildFailed ()
1815
exit $1
1916
}
2017

21-
if [ "$1" == "" ] || [ "$1" == "-E" ]; then
18+
command=%0
19+
test_mode=%1
20+
shift
21+
22+
test_track=""
23+
individual_test=""
24+
while [ "${1:-}" != "" ]; do
25+
case "$1" in
26+
"--test")
27+
shift
28+
individial_test=$1
29+
;;
30+
"--track")
31+
shift
32+
test_track=track $1
33+
;;
34+
esac
35+
shift
36+
done
37+
38+
if [ "$test_mode" == "" ] || [ "$test_mode" == "-E" ]; then
2239
"${CMAKE_COMMAND}" --build . --config Release
2340
errorVal=$?
2441
if [ "$?" == 1 ]; then
@@ -27,19 +44,19 @@ if [ "$1" == "" ] || [ "$1" == "-E" ]; then
2744
"${CMAKE_CTEST_COMMAND}" -C Release -D Experimental --output-on-failure
2845
fi
2946

30-
if [ "$1" == "-N" ]; then
47+
if [ "$test_mode" == "-N" ]; then
3148
# Clean before the nightly build to enforce all build warnings appear on all nightly dashboard submissions
3249
"${CMAKE_COMMAND}" --build . --config Release --clean-first
3350
"${CMAKE_CTEST_COMMAND}" -C Release -D Nightly
3451
fi
3552

36-
if [ "$1" == "-C" ]; then
53+
if [ "$test_mode" == "-C" ]; then
3754
"${CMAKE_CTEST_COMMAND}" -C Release -D Continuous
3855
# Wait for some time before continue to allow checking the results of the executions
3956
sleep 15
4057
fi
4158

42-
if [ "$1" == "-I" ]; then
59+
if [ "$test_mode" == "-I" ]; then
4360
# Run individual tests with regexp search
4461
# Display the list of tests
4562
"${CMAKE_CTEST_COMMAND}" -R "%2" -N -C Release

0 commit comments

Comments
 (0)