Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overwrite Ctest default timeout 1500 in CMakeLists.txt

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?

like image 461
Joachim W Avatar asked Jul 10 '17 10:07

Joachim W


1 Answers

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.

like image 121
Craig Scott Avatar answered Oct 18 '22 19:10

Craig Scott