summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-result.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-result.txt)0
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-stdout.txt)0
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-result.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-result.txt)0
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stderr.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stderr.txt)0
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stdout.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stdout.txt)2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt8
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stdout.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest.cmake8
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake62
-rw-r--r--Tests/RunCMake/GoogleTest/timeout_test.cpp7
11 files changed, 68 insertions, 34 deletions
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-result.txt
index d197c91..d197c91 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-result.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-result.txt
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt
index 3a6572c..3a6572c 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-result.txt
index d197c91..d197c91 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-build-result.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-result.txt
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stderr.txt
index f6be939..f6be939 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stderr.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stderr.txt
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stdout.txt
index d4c4e7b..d9de3f8 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-test-stdout.txt
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-test-stdout.txt
@@ -1,4 +1,4 @@
-Test project .*GoogleTest-build
+Test project .*GoogleTest-discovery-timeout
[ \t]*Start [0-9]+: discovery_timeout_test_NOT_BUILT
Could not find executable discovery_timeout_test_NOT_BUILT
Looked in the following places:
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt
new file mode 100644
index 0000000..75afe4a
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\):
+[ \t]*Error running test executable.
++
+[ \t]*Path: '.*discovery_timeout_test(\.exe)?'
+[ \t]*Result: Process terminated due to timeout
+[ \t]*Output:
+[ \t]*timeout.
+[ \t]*case
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stdout.txt
new file mode 100644
index 0000000..d65061f
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stdout.txt
@@ -0,0 +1 @@
+Test project .*GoogleTest-discovery-timeout
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
index 31808c6..4bc6b9d 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake
+++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
@@ -49,11 +49,3 @@ gtest_discover_tests(
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/GoogleTestDiscoveryTimeout.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake
new file mode 100644
index 0000000..7398faf
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTimeout.cmake
@@ -0,0 +1,14 @@
+project(test_include_dirs)
+include(CTest)
+include(GoogleTest)
+
+enable_testing()
+
+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
+ DISCOVERY_MODE ${DISCOVERY_MODE}
+)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
index 8070512..97a777b 100644
--- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -1,6 +1,6 @@
include(RunCMake)
-function(run_GoogleTest)
+function(run_GoogleTest DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build)
set(RunCMake_TEST_NO_CLEAN 1)
@@ -10,7 +10,7 @@ function(run_GoogleTest)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
- run_cmake(GoogleTest)
+ run_cmake_with_options(GoogleTest -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTest-build
${CMAKE_COMMAND}
@@ -26,15 +26,6 @@ function(run_GoogleTest)
--target property_timeout_test
)
- set(RunCMake_TEST_OUTPUT_MERGE 1)
- run_cmake_command(GoogleTest-discovery-timeout-build
- ${CMAKE_COMMAND}
- --build .
- --config Debug
- --target discovery_timeout_test
- )
- set(RunCMake_TEST_OUTPUT_MERGE 0)
-
run_cmake_command(GoogleTest-test1
${CMAKE_CTEST_COMMAND}
-C Debug
@@ -69,16 +60,9 @@ function(run_GoogleTest)
-R property_timeout\\.case_with_discovery
--no-label-summary
)
-
- run_cmake_command(GoogleTest-discovery-timeout-test
- ${CMAKE_CTEST_COMMAND}
- -C Debug
- -R discovery_timeout_test
- --no-label-summary
- )
endfunction()
-function(run_GoogleTestXML)
+function(run_GoogleTestXML DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTestXML-build)
set(RunCMake_TEST_NO_CLEAN 1)
@@ -88,7 +72,7 @@ function(run_GoogleTestXML)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
- run_cmake(GoogleTestXML)
+ run_cmake_with_options(GoogleTestXML -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTestXML-discovery
${CMAKE_COMMAND}
@@ -105,5 +89,39 @@ function(run_GoogleTestXML)
)
endfunction()
-run_GoogleTest()
-run_GoogleTestXML()
+function(run_GoogleTest_discovery_timeout DISCOVERY_MODE)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-timeout)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake_with_options(GoogleTestDiscoveryTimeout -DDISCOVERY_MODE=${DISCOVERY_MODE})
+
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(GoogleTest-discovery-${DISCOVERY_MODE}-timeout-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target discovery_timeout_test
+ )
+ set(RunCMake_TEST_OUTPUT_MERGE 0)
+
+ run_cmake_command(GoogleTest-discovery-${DISCOVERY_MODE}-timeout-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R discovery_timeout_test
+ --no-label-sumary
+ )
+endfunction()
+
+foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
+ message("Testing ${DISCOVERY_MODE} discovery mode via CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE global override...")
+ run_GoogleTest(${DISCOVERY_MODE})
+ run_GoogleTestXML(${DISCOVERY_MODE})
+ message("Testing ${DISCOVERY_MODE} discovery mode via DISCOVERY_MODE option...")
+ run_GoogleTest_discovery_timeout(${DISCOVERY_MODE})
+endforeach()
diff --git a/Tests/RunCMake/GoogleTest/timeout_test.cpp b/Tests/RunCMake/GoogleTest/timeout_test.cpp
index b8ad055..5506269 100644
--- a/Tests/RunCMake/GoogleTest/timeout_test.cpp
+++ b/Tests/RunCMake/GoogleTest/timeout_test.cpp
@@ -4,9 +4,10 @@
# include <unistd.h>
#endif
-#include <iostream>
#include <string>
+#include <stdio.h>
+
void sleepFor(unsigned seconds)
{
#if defined(_WIN32)
@@ -23,8 +24,8 @@ int main(int argc, char** argv)
// 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;
+ printf("timeout.\n case\n");
+ fflush(stdout);
#ifdef discoverySleepSec
sleepFor(discoverySleepSec);
#endif