diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2017-11-28 15:52:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-06 12:37:48 (GMT) |
commit | 29731d89192681cbc4bf87d7947a877aa0fb27aa (patch) | |
tree | 7da7ff6db386d5ff54382af3b106c8a50e1b86fa /Modules/GoogleTest.cmake | |
parent | e99e39829ba36dbfad189a94062363343d7d3d8b (diff) | |
download | CMake-29731d89192681cbc4bf87d7947a877aa0fb27aa.zip CMake-29731d89192681cbc4bf87d7947a877aa0fb27aa.tar.gz CMake-29731d89192681cbc4bf87d7947a877aa0fb27aa.tar.bz2 |
GoogleTest: Add timeout to discovery
Add a TIMEOUT option to gtest_discover_tests. This provides a
work-around in case a test goes out to lunch, rather than causing the
build to simply hang. (Although this is still a problem with the user's
project, hanging the build is not cool, especially in the case of
automatically running CI builds. It is much preferred that the build
should actively fail in this case, and it is trivially easy for us to
implement that.)
Diffstat (limited to 'Modules/GoogleTest.cmake')
-rw-r--r-- | Modules/GoogleTest.cmake | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index 3d47367..c525101 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -217,6 +217,14 @@ same as the Google Test name (i.e. ``suite.testcase``); see also executable is being used in multiple calls to ``gtest_discover_tests()``. Note that this variable is only available in CTest. + ``TIMEOUT num`` + Specifies how long (in seconds) CMake will wait for the test to enumerate + available tests. If the test takes longer than this, discovery (and your + build) will fail. Most test executables will enumerate their tests very + quickly, but under some exceptional circumstances, a test may require a + longer timeout. The default is 5. See also the ``TIMEOUT`` option of + :command:`execute_process`. + #]=======================================================================] #------------------------------------------------------------------------------ @@ -349,7 +357,7 @@ function(gtest_discover_tests TARGET) cmake_parse_arguments( "" "NO_PRETTY_TYPES;NO_PRETTY_VALUES" - "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;TIMEOUT" "EXTRA_ARGS;PROPERTIES" ${ARGN} ) @@ -360,6 +368,9 @@ function(gtest_discover_tests TARGET) if(NOT _TEST_LIST) set(_TEST_LIST ${TARGET}_TESTS) endif() + if(NOT _TIMEOUT) + set(_TIMEOUT 5) + endif() get_property( has_counter @@ -407,6 +418,7 @@ function(gtest_discover_tests TARGET) -D "NO_PRETTY_VALUES=${_NO_PRETTY_VALUES}" -D "TEST_LIST=${_TEST_LIST}" -D "CTEST_FILE=${ctest_tests_file}" + -D "TEST_DISCOVERY_TIMEOUT=${_TIMEOUT}" -P "${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}" VERBATIM ) |