diff options
Diffstat (limited to 'Tests/RunCMake')
19 files changed, 107 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c7fe649..d22c39c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -217,6 +217,7 @@ add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) +add_RunCMake_test(CTestTimeoutAfterMatch) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) @@ -234,7 +235,10 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) - add_RunCMake_test(VSSolution) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) + set(NO_USE_FOLDERS 1) + endif() + add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS}) endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^789]|[789][0-9])") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in new file mode 100644 index 0000000..e9592f6 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4) +project(TimeoutAfterMatch NONE) +include(CTest) +add_test(NAME SleepFor1Second COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_SOURCE_DIR}/SleepFor1Second.cmake) +set_property(TEST SleepFor1Second PROPERTY TIMEOUT 30) +set_property(TEST SleepFor1Second PROPERTY TIMEOUT_AFTER_MATCH "${arg1}" "${arg2}") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in new file mode 100644 index 0000000..58b11af --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in @@ -0,0 +1 @@ +set(CTEST_PROJECT_NAME "TimeoutAfterMatch@CASE_NAME@") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt new file mode 100644 index 0000000..7766c68 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt @@ -0,0 +1 @@ +TIMEOUT_AFTER_MATCH expects two arguments, found 1 diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt new file mode 100644 index 0000000..7766c68 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt @@ -0,0 +1 @@ +TIMEOUT_AFTER_MATCH expects two arguments, found 1 diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake new file mode 100644 index 0000000..ee4db83 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCTest) + +function(run_ctest_TimeoutAfterMatch CASE_NAME) + set(CASE_PROPERTY_ARGS "${ARGN}") + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_TimeoutAfterMatch(MissingArg1 "\"-Darg2=Test started\"") +run_ctest_TimeoutAfterMatch(MissingArg2 "\"-Darg1=2\"") +run_ctest_TimeoutAfterMatch(ShouldTimeout "\"-Darg1=1\" \"-Darg2=Test started\"") +run_ctest_TimeoutAfterMatch(ShouldPass "\"-Darg1=15\" \"-Darg2=Test started\"") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt new file mode 100644 index 0000000..89aae56 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt @@ -0,0 +1,6 @@ + Start 1: SleepFor1Second +1/1 Test #1: SleepFor1Second .................. Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt new file mode 100644 index 0000000..c031eb0 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt @@ -0,0 +1 @@ +1 - SleepFor1Second \(Timeout\) diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake new file mode 100644 index 0000000..82c2a44 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake @@ -0,0 +1,4 @@ +execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Gathering required resources") +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) +execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Test started") +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in new file mode 100644 index 0000000..d049c9f --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.4) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +configure_file( + "@RunCMake_SOURCE_DIR@/SleepFor1Second.cmake" + "${CTEST_SOURCE_DIRECTORY}/SleepFor1Second.cmake" + COPYONLY) + +set(options @CASE_PROPERTY_ARGS@) + +ctest_start(Experimental) +ctest_configure(OPTIONS "${options}") +ctest_test() diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index 6ae158d..afd74a1 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -8,3 +8,9 @@ run_cmake(MorePost) run_cmake(PrePost) run_cmake(Override1) run_cmake(Override2) +run_cmake(StartupProject) +run_cmake(StartupProjectMissing) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) + run_cmake(StartupProjectUseFolders) +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake new file mode 100644 index 0000000..f36aab2 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "TestStartup") + error("TestStartup is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject.cmake b/Tests/RunCMake/VSSolution/StartupProject.cmake new file mode 100644 index 0000000..7192f3d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject.cmake @@ -0,0 +1,2 @@ +add_custom_target(TestStartup) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake new file mode 100644 index 0000000..b1017dd --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "ALL_BUILD") + error("ALL_BUILD is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt new file mode 100644 index 0000000..da92c6d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + Directory property VS_STARTUP_PROJECT specifies target 'DoesNotExist' that + does not exist. Ignoring. +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake new file mode 100644 index 0000000..907a877 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "DoesNotExist") diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake new file mode 100644 index 0000000..c0a545a --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake @@ -0,0 +1,9 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "CMakePredefinedTargets") + error("CMakePredefinedTargets is not the first project") +endif() +list(GET projects 1 second_project) +if(NOT second_project STREQUAL "TestStartup") + error("TestStartup does not immediately follow the CMakePredefinedTargets project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake new file mode 100644 index 0000000..8e422a4 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake @@ -0,0 +1,3 @@ +add_custom_target(TestStartup) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index dd158ef..4e5bb59 100644 --- a/Tests/RunCMake/VSSolution/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,6 +50,21 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() +macro(getProjectNames arg_out_projects) + set(${arg_out_projects} "") + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + if(NOT EXISTS "${sln}") + error("Expected solution file ${sln} does not exist") + endif() + file(STRINGS "${sln}" project_lines REGEX "^Project\\(") + foreach(project_line IN LISTS project_lines) + string(REGEX REPLACE ".* = \"" "" project_line "${project_line}") + string(REGEX REPLACE "\", .*" "" project_line "${project_line}") + list(APPEND ${arg_out_projects} "${project_line}") + endforeach() +endmacro() + + macro(testGlobalSection prefix sectionName) if(NOT DEFINED ${prefix}_${sectionName}) error("Section ${sectionName} does not exist") |