diff options
author | Johnny Jazeix <jazeix@gmail.com> | 2020-04-20 21:05:15 (GMT) |
---|---|---|
committer | Johnny Jazeix <jazeix@gmail.com> | 2020-04-20 21:05:15 (GMT) |
commit | e89aeba5c4733964db15e0d147e063af34205d54 (patch) | |
tree | 2b5e1da00d132d9e60b8355f6de72427b44faa62 /Tests | |
parent | df2d39bc512bd09ae808e8a2a6c7523737bb26c0 (diff) | |
download | CMake-e89aeba5c4733964db15e0d147e063af34205d54.zip CMake-e89aeba5c4733964db15e0d147e063af34205d54.tar.gz CMake-e89aeba5c4733964db15e0d147e063af34205d54.tar.bz2 |
ctest: add option --stop-on-failure
To stop the tests once one has failed
Fixes: #16628
Diffstat (limited to 'Tests')
6 files changed, 51 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 9b9ae65..20deb59 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -242,6 +242,20 @@ function(run_TestOutputSize) endfunction() run_TestOutputSize() +# Test --stop-on-failure +function(run_stop_on_failure) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/stop-on-failure) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " +add_test(test1 \"${CMAKE_COMMAND}\" -E false) +add_test(test2 \"${CMAKE_COMMAND}\" -E echo \"not running\") +") + run_cmake_command(stop-on-failure ${CMAKE_CTEST_COMMAND} --stop-on-failure) +endfunction() +run_stop_on_failure() + function(run_TestAffinity) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestAffinity) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/CTestCommandLine/stop-on-failure-result.txt b/Tests/RunCMake/CTestCommandLine/stop-on-failure-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/stop-on-failure-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CTestCommandLine/stop-on-failure-stderr.txt b/Tests/RunCMake/CTestCommandLine/stop-on-failure-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/stop-on-failure-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/CTestCommandLine/stop-on-failure-stdout.txt b/Tests/RunCMake/CTestCommandLine/stop-on-failure-stdout.txt new file mode 100644 index 0000000..12c77d0 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/stop-on-failure-stdout.txt @@ -0,0 +1,10 @@ +^Test project .*/Tests/RunCMake/CTestCommandLine/stop-on-failure + Start 1: test1 +1/2 Test #1: test1 ............................\*\*\*Failed +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+1 - test1 \(Failed\)$ diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 84d1d66..34d4020 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -95,3 +95,15 @@ endfunction() run_TestRepeat(UntilFail REPEAT UNTIL_FAIL:3) run_TestRepeat(UntilPass REPEAT UNTIL_PASS:3) run_TestRepeat(AfterTimeout REPEAT AFTER_TIMEOUT:3) + +# test --stop-on-failure +function(run_stop_on_failure) + set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME StoppingTest COMMAND ${CMAKE_COMMAND} -E false) +add_test(NAME NotRunTest COMMAND ${CMAKE_COMMAND} -E true) + ]]) + + run_ctest_test(stop-on-failure STOP_ON_FAILURE) +endfunction() +run_stop_on_failure() diff --git a/Tests/RunCMake/ctest_test/stop-on-failure-stdout.txt b/Tests/RunCMake/ctest_test/stop-on-failure-stdout.txt new file mode 100644 index 0000000..fa4bce0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/stop-on-failure-stdout.txt @@ -0,0 +1,13 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/stop-on-failure-build + Start 1: RunCMakeVersion +1/3 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + Start 2: StoppingTest +2/3 Test #2: StoppingTest .....................\*\*\*Failed +[0-9.]+ sec ++ +50% tests passed, 1 tests failed out of 2 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+2 - StoppingTest \(Failed\)$ |