How to overwrite Ctest default timeout 1500 in CMakeLists.txt
Asked Answered
A

1

25

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?

Apeldoorn answered 10/7, 2017 at 10:23 Comment(0)
S
41

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.

Subcommittee answered 10/7, 2017 at 18:10 Comment(3)
"You can control the timeout in CMake for individual tests with the TIMEOUT test property" - how would I do this?Apeldoorn
Is there a global setting for CMakeLists.txt files? Just like many other properties have global defaults, e.g CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS and WINDOWS_EXPORT_ALL_SYMBOLS.Symposiarch
There's nothing you can put directly in a CMakeLists.txt file to control it. The CTEST_TEST_TIMEOUT variable can be put in a CTest dashboard script, but that's as close as you can get currently.Subcommittee

© 2022 - 2024 — McMap. All rights reserved.