My CMakeLists.txt includes the lines
include(CTest)
enable_testing()
set(CTEST_TEST_TIMEOUT 3)
add_test(...)
ctest works, but ignores my attempt to set the timeout. Rather, it runs with the default timeout of 1500.
How to change the default timeout? How is CTEST_TEST_TIMEOUT meant to be used?
CTEST_TEST_TIMEOUT is for use within the CTest script, not a CMakeLists.txt file. You can control the timeout in CMake for individual tests with the TIMEOUT test property, but there isn't a CMake variable that sets the global timeout default. The following sets the timeout to 30 seconds for just the sometest test:
add_test(sometest ...)
set_tests_properties(sometest PROPERTIES TIMEOUT 30)
You can, however, override the default timeout when you invoke ctest using the --timeout option. E.g. to run the tests with the global timeout default set to 120 seconds:
ctest --timeout 120
A timeout specified in CMake for an individual test still takes precedence over the globally set default timeout, even when the --timeout option is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With