diff options
author | Brad King <brad.king@kitware.com> | 2018-03-16 11:52:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-16 11:52:23 (GMT) |
commit | df27bd3f83f3854df24bce9b0a57b425b0396585 (patch) | |
tree | ef42c83ecd6861a5d59b8263f0f491622859c5ef /Tests | |
parent | 298e1bfe2870d649ed1ec0054137d6417c7d5ef2 (diff) | |
parent | 96fdde26bbbc969944e556ad649191cd21f46990 (diff) | |
download | CMake-df27bd3f83f3854df24bce9b0a57b425b0396585.zip CMake-df27bd3f83f3854df24bce9b0a57b425b0396585.tar.gz CMake-df27bd3f83f3854df24bce9b0a57b425b0396585.tar.bz2 |
Merge branch 'gtest_discover_tests_timeout' into release-3.11
Merge-request: !1851
Diffstat (limited to 'Tests')
13 files changed, 113 insertions, 10 deletions
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt index d197c91..d197c91 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt index 8464c80..3a6572c 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt @@ -1,7 +1,7 @@ ( *|[0-9]+>)CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\): ( *|[0-9]+>) Error running test executable. ?( *|[0-9]+>) -( *|[0-9]+>) Path: '.*timeout_test(\.exe)?' +( *|[0-9]+>) Path: '.*discovery_timeout_test(\.exe)?' ( *|[0-9]+>) Result: Process terminated due to timeout ( *|[0-9]+>) Output: ( *|[0-9]+>) + diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt new file mode 100644 index 0000000..0dda49d --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt @@ -0,0 +1,10 @@ +Test project .*GoogleTest-build +[ \t]*Start [0-9]+: property_timeout.case_no_discovery +[^\n]+property_timeout.case_no_discovery +\.+\*\*\*Timeout +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[^\n]*property_timeout.case_no_discovery \(Timeout\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt new file mode 100644 index 0000000..72cea55 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt @@ -0,0 +1,10 @@ +Test project .*GoogleTest-build +[ \t]*Start [0-9]+: property_timeout.case_with_discovery +[^\n]+property_timeout.case_with_discovery +\.+\*\*\*Timeout +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[^\n]*property_timeout.case_with_discovery \(Timeout\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt index 55a4a7a..a4cc971 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt @@ -1,2 +1,2 @@ -Unable to find executable: timeout_test_NOT_BUILT +Unable to find executable: no_tests_defined_NOT_BUILT Errors while running CTest diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 5e4b8ef..31808c6 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -22,8 +22,38 @@ gtest_discover_tests( PROPERTIES LABELS TEST2 ) -add_executable(timeout_test timeout_test.cpp) +add_executable(no_tests_defined no_tests_defined.cpp) gtest_discover_tests( - timeout_test + no_tests_defined +) + +# Note change in behavior of TIMEOUT keyword in 3.10.3 +# where it was renamed to DISCOVERY_TIMEOUT to prevent it +# from shadowing the TIMEOUT test property. Verify the +# 3.10.3 and later behavior, old behavior added in 3.10.1 +# is not supported. +add_executable(property_timeout_test timeout_test.cpp) +target_compile_definitions(property_timeout_test PRIVATE sleepSec=10) + +gtest_discover_tests( + property_timeout_test + TEST_PREFIX property_ + TEST_SUFFIX _no_discovery + PROPERTIES TIMEOUT 2 +) +gtest_discover_tests( + property_timeout_test + TEST_PREFIX property_ + TEST_SUFFIX _with_discovery + DISCOVERY_TIMEOUT 20 + PROPERTIES TIMEOUT 2 +) + +add_executable(discovery_timeout_test timeout_test.cpp) +target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10) +gtest_discover_tests( + discovery_timeout_test + TEST_PREFIX discovery_ + DISCOVERY_TIMEOUT 2 ) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index 209e769..0fa4e2a 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -19,12 +19,19 @@ function(run_GoogleTest) --target fake_gtest ) + run_cmake_command(GoogleTest-property-timeout-exe + ${CMAKE_COMMAND} + --build . + --config Debug + --target property_timeout_test + ) + set(RunCMake_TEST_OUTPUT_MERGE 1) - run_cmake_command(GoogleTest-timeout + run_cmake_command(GoogleTest-discovery-timeout ${CMAKE_COMMAND} --build . --config Debug - --target timeout_test + --target discovery_timeout_test ) set(RunCMake_TEST_OUTPUT_MERGE 0) @@ -45,7 +52,21 @@ function(run_GoogleTest) run_cmake_command(GoogleTest-test-missing ${CMAKE_CTEST_COMMAND} -C Debug - -R timeout + -R no_tests_defined + --no-label-summary + ) + + run_cmake_command(GoogleTest-property-timeout1 + ${CMAKE_CTEST_COMMAND} + -C Debug + -R property_timeout\\.case_no_discovery + --no-label-summary + ) + + run_cmake_command(GoogleTest-property-timeout2 + ${CMAKE_CTEST_COMMAND} + -C Debug + -R property_timeout\\.case_with_discovery --no-label-summary ) endfunction() diff --git a/Tests/RunCMake/GoogleTest/no_tests_defined.cpp b/Tests/RunCMake/GoogleTest/no_tests_defined.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/GoogleTest/no_tests_defined.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/GoogleTest/timeout_test.cpp b/Tests/RunCMake/GoogleTest/timeout_test.cpp index a8e5c1c..9162dcf 100644 --- a/Tests/RunCMake/GoogleTest/timeout_test.cpp +++ b/Tests/RunCMake/GoogleTest/timeout_test.cpp @@ -4,12 +4,36 @@ #include <unistd.h> #endif -int main() +#include <iostream> +#include <string> + +void sleepFor(unsigned seconds) { #if defined(_WIN32) - Sleep(10000); + Sleep(seconds * 1000); #else - sleep(10); + sleep(seconds); +#endif +} + +int main(int argc, char** argv) +{ + // Note: GoogleTest.cmake doesn't actually depend on Google Test as such; + // it only requires that we produce output in the expected format when + // invoked with --gtest_list_tests. Thus, we fake that here. This allows us + // to test the module without actually needing Google Test. + if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { + std::cout << "timeout." << std::endl; + std::cout << " case" << std::endl; +#ifdef discoverySleepSec + sleepFor(discoverySleepSec); +#endif + return 0; + } + +#ifdef sleepSec + sleepFor(sleepSec); #endif + return 0; } |