summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorZack Galbreath <zack.galbreath@kitware.com>2016-02-18 18:59:18 (GMT)
committerBrad King <brad.king@kitware.com>2016-03-22 15:17:55 (GMT)
commit993e48d0451b41f8e2c2a59473d9ddc09ada5792 (patch)
treeef678a032f62e84338653b903e6be7ebc0522d2b /Tests/RunCMake
parent2b64dc7cabb6eda86f0c8b91b27aee4119ac7ebb (diff)
downloadCMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.zip
CMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.tar.gz
CMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.tar.bz2
CTest: Optionally use a secondary test timeout after matching output
Allow a test N seconds to complete after we detect a matching line in its output. Activate this behavior with a new TIMEOUT_AFTER_MATCH test property.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in6
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt6
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt1
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake4
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in21
10 files changed, 53 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 588f3a1..7e7ed45 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)
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()