Skip to content

Commit

Permalink
Adding argument parsing to script to enable --track argument to CTest (
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrankin authored Oct 26, 2018
1 parent 5d44f33 commit 781b35d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
48 changes: 33 additions & 15 deletions BuildAndTest.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@

SET BUILD_TYPE=Release

REM Skip build step if continuous or individual mode
REM Parse arguments
SET COMMAND=%0
SET TEST_MODE=%1
SHIFT

:loop
IF NOT "%1"=="" (
IF "%1"=="--test" (
SET INDIVIDUAL_TEST=%2
SHIFT
)
IF "%1"=="--track" (
SET TEST_TRACK=--track %2
SHIFT
)
SHIFT
GOTO :loop
)

REM Skip build step if continuous or individual mode
REM Skip clean build step if not nightly mode
if "%1" == "-C" goto cleansuccess
if "%1" == "-I" goto cleansuccess
if "%1" == "" goto cleansuccess
if "%1" == "-E" goto cleansuccess
if "%TEST_MODE%" == "-C" goto cleansuccess
if "%TEST_MODE%" == "-I" goto cleansuccess
if "%TEST_MODE%" == "" goto cleansuccess
if "%TEST_MODE%" == "-E" goto cleansuccess

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

rem ---------------------------------------
if "%1" == "" goto experimental
if "%1" == "-E" goto experimental
if "%1" == "-N" goto nightly
if "%1" == "-C" goto continuous
if "%1" == "-I" goto individual
if "%TEST_MODE%" == "" goto experimental
if "%TEST_MODE%" == "-E" goto experimental
if "%TEST_MODE%" == "-N" goto nightly
if "%TEST_MODE%" == "-C" goto continuous
if "%TEST_MODE%" == "-I" goto individual

:experimental
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Experimental --output-on-failure
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -D Experimental --output-on-failure %TEST_TRACK%
goto success

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

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

:individual
@REM Run individual tests with regexp search
@REM Display the list of tests
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%2" -N
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%INDIVIDUAL_TEST%" -N %TEST_TRACK%
@REM Run selected tests
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%2" -V
"${CMAKE_CTEST_COMMAND}" -C %BUILD_TYPE% -R "%INDIVIDUAL_TEST%" -V %TEST_TRACK%
goto success

:success
Expand Down
31 changes: 24 additions & 7 deletions BuildAndTest.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
ORIGPATH=$PATH
DIRCMD=0

# Prevent X server related test errors (vtkXOpenGLRenderWindow: bad X server connection)
export DISPLAY=:0

finish()
{
PATH=$ORIGPATH
Expand All @@ -18,7 +15,27 @@ buildFailed ()
exit $1
}

if [ "$1" == "" ] || [ "$1" == "-E" ]; then
command=%0
test_mode=%1
shift

test_track=""
individual_test=""
while [ "${1:-}" != "" ]; do
case "$1" in
"--test")
shift
individial_test=$1
;;
"--track")
shift
test_track=track $1
;;
esac
shift
done

if [ "$test_mode" == "" ] || [ "$test_mode" == "-E" ]; then
"${CMAKE_COMMAND}" --build . --config Release
errorVal=$?
if [ "$?" == 1 ]; then
Expand All @@ -27,19 +44,19 @@ if [ "$1" == "" ] || [ "$1" == "-E" ]; then
"${CMAKE_CTEST_COMMAND}" -C Release -D Experimental --output-on-failure
fi

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

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

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

0 comments on commit 781b35d

Please sign in to comment.