diff options
Diffstat (limited to 'Tests')
15 files changed, 122 insertions, 10 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 983f7e4..868eb24 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -416,7 +416,7 @@ endif() if(TARGET ctresalloc) add_RunCMake_test(CTestResourceAllocation -DCTRESALLOC_COMMAND=$<TARGET_FILE:ctresalloc>) else() - message(WARNING "Could not find or build ctresalloc") + message(STATUS "Could not find ctresalloc") endif() find_package(Qt4 QUIET) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt index 4cb051d..928d88a 100644 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt @@ -2,7 +2,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "configure" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) @@ -12,7 +12,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "build" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) @@ -22,7 +22,7 @@ CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): Using NO_DEPENDS for "install" step might break parallel builds Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt new file mode 100644 index 0000000..0e21b8f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs-build-stdout.txt @@ -0,0 +1,21 @@ +.*-- Number of arguments for download: 6 +.*-- download argument 4: '' +.*-- download argument 5: 'after' +.*-- Number of arguments for update: 6 +.*-- update argument 4: '' +.*-- update argument 5: 'after' +.*-- Number of arguments for patch: 6 +.*-- patch argument 4: '' +.*-- patch argument 5: 'after' +.*-- Number of arguments for configure: 6 +.*-- configure argument 4: '' +.*-- configure argument 5: 'after' +.*-- Number of arguments for build: 6 +.*-- build argument 4: '' +.*-- build argument 5: 'after' +.*-- Number of arguments for install: 6 +.*-- install argument 4: '' +.*-- install argument 5: 'after' +.*-- Number of arguments for test: 6 +.*-- test argument 4: '' +.*-- test argument 5: 'after' diff --git a/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..ded1000 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(ExternalProject) + +set(script "${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake") +ExternalProject_Add( + blankChecker + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P "${script}" download "" after + UPDATE_COMMAND ${CMAKE_COMMAND} -P "${script}" update "" after + PATCH_COMMAND ${CMAKE_COMMAND} -P "${script}" patch "" after + CONFIGURE_COMMAND ${CMAKE_COMMAND} -P "${script}" configure "" after + BUILD_COMMAND ${CMAKE_COMMAND} -P "${script}" build "" after + INSTALL_COMMAND ${CMAKE_COMMAND} -P "${script}" install "" after + TEST_COMMAND ${CMAKE_COMMAND} -P "${script}" test "" after +) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index caaf0d2..0d1da26 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -29,6 +29,10 @@ endfunction() __ep_test_with_build(MultiCommand) +set(RunCMake_TEST_OUTPUT_MERGE 1) +__ep_test_with_build(PreserveEmptyArgs) +set(RunCMake_TEST_OUTPUT_MERGE 0) + # Output is not predictable enough to be able to verify it reliably # when using the various different Visual Studio generators if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") diff --git a/Tests/RunCMake/ExternalProject/countArgs.cmake b/Tests/RunCMake/ExternalProject/countArgs.cmake new file mode 100644 index 0000000..ee6429a --- /dev/null +++ b/Tests/RunCMake/ExternalProject/countArgs.cmake @@ -0,0 +1,5 @@ +message(STATUS "Number of arguments for ${CMAKE_ARGV3}: ${CMAKE_ARGC}") +math(EXPR last "${CMAKE_ARGC} - 1") +foreach(n RANGE 4 ${last}) + message(STATUS "${CMAKE_ARGV3} argument ${n}: '${CMAKE_ARGV${n}}'") +endforeach() diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt new file mode 100644 index 0000000..a72d914 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs-stdout.txt @@ -0,0 +1,4 @@ +.*-- Number of arguments: 6 +.*-- Argument 3: 'before' +.*-- Argument 4: '' +.*-- Argument 5: 'after' diff --git a/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..4f35448 --- /dev/null +++ b/Tests/RunCMake/FetchContent/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(FetchContent) + +# Need to see the download command output +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + t1 + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake + before "" after +) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 5e2e5e1..f3ed3e2 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -16,6 +16,10 @@ run_cmake(MakeAvailable) run_cmake(MakeAvailableTwice) run_cmake(MakeAvailableUndeclared) +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_cmake(PreserveEmptyArgs) +set(RunCMake_TEST_OUTPUT_MERGE 0) + # We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM # to ensure the test can run on machines where the build tool # isn't on the PATH. Some build slaves explicitly test with such diff --git a/Tests/RunCMake/FetchContent/countArgs.cmake b/Tests/RunCMake/FetchContent/countArgs.cmake new file mode 100644 index 0000000..7542af4 --- /dev/null +++ b/Tests/RunCMake/FetchContent/countArgs.cmake @@ -0,0 +1,5 @@ +message(STATUS "Number of arguments: ${CMAKE_ARGC}") +math(EXPR last "${CMAKE_ARGC} - 1") +foreach(n RANGE 3 ${last}) + message(STATUS "Argument ${n}: '${CMAKE_ARGV${n}}'") +endforeach() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 18ae793..b82335f 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -81,20 +81,46 @@ 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}) - string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ +function(run_TestRepeat case return_value ) + set(CASE_CTEST_TEST_ARGS RETURN_VALUE result EXCLUDE RunCMakeVersion ${ARGN}) + string(CONCAT suffix_code [[ add_test(NAME testRepeat COMMAND ${CMAKE_COMMAND} -D COUNT_FILE=${CMAKE_CURRENT_BINARY_DIR}/count.cmake -P "]] "${RunCMake_SOURCE_DIR}/TestRepeat${case}" [[.cmake") set_property(TEST testRepeat PROPERTY TIMEOUT 5) ]]) + string(APPEND CASE_CMAKELISTS_SUFFIX_CODE "${suffix_code}") 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) + +# test repeat and not run tests interact correctly +set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME testNotRun + COMMAND ${CMAKE_COMMAND}/doesnt_exist) + set_property(TEST testNotRun PROPERTY TIMEOUT 5) + ]]) +run_TestRepeat(NotRun RETURN_VALUE:1 REPEAT UNTIL_PASS:3) +unset(CASE_CMAKELISTS_SUFFIX_CODE) # test --stop-on-failure function(run_stop_on_failure) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt new file mode 100644 index 0000000..a69932d --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt @@ -0,0 +1 @@ +.*Unable to find executable.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt new file mode 100644 index 0000000..72c98bc --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt @@ -0,0 +1,5 @@ +.* +50% tests passed, 1 tests failed out of 2 +.* +The following tests FAILED: +.*testNotRun.*Not Run.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake new file mode 100644 index 0000000..abde4f0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake @@ -0,0 +1,10 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() |