diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-05-26 15:36:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-05-27 10:39:17 (GMT) |
commit | c5032519974ae8649036f0b85a7100632dc064a5 (patch) | |
tree | 61d61743446ece7fdc53616be9ed16b12e65c471 /Tests/RunCMake/ctest_test | |
parent | 615129f3ebd308abeaaee7f5f0689e7fc4616c28 (diff) | |
download | CMake-c5032519974ae8649036f0b85a7100632dc064a5.zip CMake-c5032519974ae8649036f0b85a7100632dc064a5.tar.gz CMake-c5032519974ae8649036f0b85a7100632dc064a5.tar.bz2 |
Tests: Add coverage of ctest_test RETURN_VALUE and REPEAT
Diffstat (limited to 'Tests/RunCMake/ctest_test')
-rw-r--r-- | Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 84d1d66..71d6b54 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -81,8 +81,8 @@ run_TestOutputSize() run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) -function(run_TestRepeat case) - set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion ${ARGN}) +function(run_TestRepeat case return_value ) + set(CASE_CTEST_TEST_ARGS RETURN_VALUE result EXCLUDE RunCMakeVersion ${ARGN}) string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ add_test(NAME testRepeat COMMAND ${CMAKE_COMMAND} -D COUNT_FILE=${CMAKE_CURRENT_BINARY_DIR}/count.cmake @@ -91,7 +91,23 @@ set_property(TEST testRepeat PROPERTY TIMEOUT 5) ]]) run_ctest(TestRepeat${case}) + + #write to end of the test file logic to Verify we get the expected + #return code + string(REPLACE "RETURN_VALUE:" "" return_value "${return_value}" ) + file(APPEND "${RunCMake_BINARY_DIR}/TestRepeat${case}/test.cmake" +" + + set(expected_result ${return_value}) + message(STATUS \${result}) + if(NOT result EQUAL expected_result) + message(FATAL_ERROR \"expected a return value of: \${expected_result}, + instead got: \${result}\") + endif() +" + ) endfunction() -run_TestRepeat(UntilFail REPEAT UNTIL_FAIL:3) -run_TestRepeat(UntilPass REPEAT UNTIL_PASS:3) -run_TestRepeat(AfterTimeout REPEAT AFTER_TIMEOUT:3) + +run_TestRepeat(UntilFail RETURN_VALUE:1 REPEAT UNTIL_FAIL:3) +run_TestRepeat(UntilPass RETURN_VALUE:0 REPEAT UNTIL_PASS:3) +run_TestRepeat(AfterTimeout RETURN_VALUE:0 REPEAT AFTER_TIMEOUT:3) |