summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake9
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake3
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake9
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake3
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt)0
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt)2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest.cmake34
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake27
-rw-r--r--Tests/RunCMake/GoogleTest/no_tests_defined.cpp4
-rw-r--r--Tests/RunCMake/GoogleTest/timeout_test.cpp30
18 files changed, 138 insertions, 13 deletions
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
index 5078f30..20bd601 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
@@ -32,7 +32,9 @@ target_link_libraries(consumer upstream config_specific)
target_compile_options(consumer PRIVATE -Werror=unused-variable)
add_library(iface IMPORTED INTERFACE)
-set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only")
+set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+ "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only>"
+ )
add_library(imported_consumer imported_consumer.cpp)
target_link_libraries(imported_consumer iface)
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
index cb48be7..cc5521e 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
@@ -24,3 +24,12 @@ if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
set(RunCMake_TEST_FAILED "Expected forced TEST_LIST argument")
return()
endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache")
+ return()
+endif()
+if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL argument")
+ return()
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
index dcb992d..a583e31 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
@@ -8,4 +8,5 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
DOWNLOAD_COMMAND ""
CMAKE_CACHE_ARGS
"-DFOO:STRING=$<1:BAR>$<0:BAD>"
- "-DTEST_LIST:STRING=A;B;C")
+ "-DTEST_LIST:STRING=A;B;C"
+ "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND")
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
index c84932d..2bef56e 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
@@ -24,3 +24,12 @@ if("${CMAKE_MATCH_0}" MATCHES FORCE)
set(RunCMake_TEST_FAILED "Expected not forced TEST_LIST argument")
return()
endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache")
+ return()
+endif()
+if("${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL argument")
+ return()
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
index 4b4b40e..d388315 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
@@ -8,4 +8,5 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
DOWNLOAD_COMMAND ""
CMAKE_CACHE_DEFAULT_ARGS
"-DFOO:STRING=$<1:BAR>$<0:BAD>"
- "-DTEST_LIST:STRING=A;B;C")
+ "-DTEST_LIST:STRING=A;B;C"
+ "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND")
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;
}