How to overwrite Ctest default timeout 1500 in CMakeLists.txt

My CMakeLists.txt

includes lines

include(CTest)
enable_testing()
set(CTEST_TEST_TIMEOUT 3)
add_test(...)

      

ctest

works, but ignores my attempt to set a timeout. Rather, it works with the default 1500.

How do I change the default timeout? How to use CTEST_TEST_TIMEOUT

?

+3


source to share


1 answer


CTEST_TEST_TIMEOUT

is intended to be used in a CTest script file, not a file CMakeLists.txt

. You can control the timeout in CMake for individual tests with a property TIMEOUT

, but there is no CMake variable that sets the global default. The following sets the timeout to 30 seconds just for the test sometest

:

add_test(sometest ...)
set_tests_properties(sometest PROPERTIES TIMEOUT 30) 

      

However, you can override the default timeout when called ctest

using a parameter --timeout

. For example. to run tests with a default global timeout of 120 seconds:



ctest --timeout 120

      

The timeout specified in CMake for an individual test still takes precedence over the globally set default timeout, even if the option is used --timeout

.

+4


source







All Articles