From 4b0c13a87ffb799334669f77978cc4d5e83f950a Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Tue, 10 Jan 2017 13:48:59 -0500 Subject: Tests: Add additional launcher tests Modify the launcher test to also try to build two executables, having respectively build and link errors. This is intended to test that launchers are used when running compile and link commands, as well as custom commands. (In particular, this should catch breakage such as that fixed by ce71bd9505a.) --- .../launcher_compiler_test_project/CMakeLists.txt | 7 ++ .../CTestConfig.cmake | 8 +++ .../launcher_compiler_test_project/build_error.cxx | 5 ++ .../CMakeLists.txt | 19 +++++ .../CTestConfig.cmake | 8 +++ .../command.cmake | 5 ++ .../launcher_linker_test_project/CMakeLists.txt | 7 ++ .../launcher_linker_test_project/CTestConfig.cmake | 8 +++ .../launcher_linker_test_project/link_error.cxx | 6 ++ .../launcher_test_project/CMakeLists.txt | 19 ----- .../launcher_test_project/CTestConfig.cmake | 8 --- .../launcher_test_project/command.cmake | 5 -- Tests/CTestTestLaunchers/test.cmake.in | 80 +++++++++++++--------- 13 files changed, 119 insertions(+), 66 deletions(-) create mode 100644 Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt create mode 100644 Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake create mode 100644 Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx create mode 100644 Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt create mode 100644 Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake create mode 100644 Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake create mode 100644 Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt create mode 100644 Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake create mode 100644 Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx delete mode 100644 Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt delete mode 100644 Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake delete mode 100644 Tests/CTestTestLaunchers/launcher_test_project/command.cmake diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt new file mode 100644 index 0000000..7376a40 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_compiler_test_project) + +include(CTest) + +add_executable(build_error build_error.cxx) diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake new file mode 100644 index 0000000..669b0fb --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx b/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx new file mode 100644 index 0000000..2d51693 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx @@ -0,0 +1,5 @@ +int main() +{ + int = 3; + return; +} diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt new file mode 100644 index 0000000..b31f587 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_custom_command_test_project) + +include(CTest) + +add_custom_command( + OUTPUT test1.txt + COMMAND ${CMAKE_COMMAND} + ARGS -DTESTID=1 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" +) + +add_custom_command( + OUTPUT test2.txt + COMMAND ${CMAKE_COMMAND} + ARGS -DTESTID=2 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" +) + +add_custom_target(mytarget ALL DEPENDS test1.txt test2.txt) diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake new file mode 100644 index 0000000..669b0fb --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake new file mode 100644 index 0000000..7f31af9 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake @@ -0,0 +1,5 @@ +if("${TESTID}" STREQUAL "1") + message("success") +elseif("${TESTID}" STREQUAL "2") + message(FATAL_ERROR "failure") +endif() diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt new file mode 100644 index 0000000..38980aa --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_linker_test_project) + +include(CTest) + +add_executable(link_error link_error.cxx) diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake new file mode 100644 index 0000000..669b0fb --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx b/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx new file mode 100644 index 0000000..c879be1 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx @@ -0,0 +1,6 @@ +extern int foo(); + +int main() +{ + return foo(); +} diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt deleted file mode 100644 index 06c5725..0000000 --- a/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -project(launcher_test_project) - -include(CTest) - -add_custom_command( - OUTPUT test1.txt - COMMAND ${CMAKE_COMMAND} - ARGS -DTESTID=1 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" -) - -add_custom_command( - OUTPUT test2.txt - COMMAND ${CMAKE_COMMAND} - ARGS -DTESTID=2 -P "${CMAKE_CURRENT_SOURCE_DIR}/command.cmake" -) - -add_custom_target(mytarget ALL DEPENDS test1.txt test2.txt) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake deleted file mode 100644 index 669b0fb..0000000 --- a/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(CTEST_USE_LAUNCHERS 1) -set(CTEST_PROJECT_NAME "CTestTestLaunchers") -set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "open.cdash.org") -set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/command.cmake b/Tests/CTestTestLaunchers/launcher_test_project/command.cmake deleted file mode 100644 index 7f31af9..0000000 --- a/Tests/CTestTestLaunchers/launcher_test_project/command.cmake +++ /dev/null @@ -1,5 +0,0 @@ -if("${TESTID}" STREQUAL "1") - message("success") -elseif("${TESTID}" STREQUAL "2") - message(FATAL_ERROR "failure") -endif() diff --git a/Tests/CTestTestLaunchers/test.cmake.in b/Tests/CTestTestLaunchers/test.cmake.in index 03a118a..2db1ddd 100644 --- a/Tests/CTestTestLaunchers/test.cmake.in +++ b/Tests/CTestTestLaunchers/test.cmake.in @@ -1,39 +1,51 @@ cmake_minimum_required(VERSION 2.8.12) -# Settings: -set(CTEST_DASHBOARD_SOURCE "@CMake_SOURCE_DIR@/Tests/CTestTestLaunchers") -set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTestLaunchers") -set(CTEST_SITE "@SITE@") -set(CTEST_BUILD_NAME "Launchers-@BUILDNAME@-CTestTestLaunchers") - -set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_SOURCE}/launcher_test_project") -set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/launcher_test_project-bin") -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") -set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") - -ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) - -file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ -CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ -CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ -CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ -CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ -CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ -") - -set(TEST_SUCCESS FALSE) - -ctest_start(Experimental) -ctest_configure(OPTIONS "-DCTEST_USE_LAUNCHERS=1") -ctest_build(NUMBER_ERRORS error_count) - -if("${error_count}" STREQUAL "1") - set(TEST_SUCCESS TRUE) -endif() +set(TEST_SUCCESS TRUE) + +function(run_test_case NAME WHAT) + set(_message "Testing that launchers are used when running ${WHAT}") + message(STATUS "${_message}...") + + # Settings: + set(CTEST_DASHBOARD_SOURCE "@CMake_SOURCE_DIR@/Tests/CTestTestLaunchers") + set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTestLaunchers") + set(CTEST_SITE "@SITE@") + set(CTEST_BUILD_NAME "Launchers-@BUILDNAME@-CTestTestLaunchers") + + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_SOURCE}/${NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${NAME}-bin") + set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") + set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@") + set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") + set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + + ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + + file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " + CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ + CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ + CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ + CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ + CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ + CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ + ") + + ctest_start(Experimental) + ctest_configure(OPTIONS "-DCTEST_USE_LAUNCHERS=1") + ctest_build(NUMBER_ERRORS error_count) + + if("${error_count}" STREQUAL "0") + set(TEST_SUCCESS FALSE PARENT_SCOPE) + message(STATUS "${_message}... FAIL") + else() + message(STATUS "${_message}... PASS") + endif() +endfunction() + +run_test_case(launcher_compiler_test_project "the compiler") +run_test_case(launcher_linker_test_project "the linker") +run_test_case(launcher_custom_command_test_project "a custom command") if(TEST_SUCCESS) message("CTEST_TEST_LAUNCHER_SUCCESS") -- cgit v0.12