We need to inform CTest that tests need to be terminated if they go into overtime, as follows:
- We define the project name, enable testing, and define the test:
# set minimum cmake versioncmake_minimum_required(VERSION 3.5 FATAL_ERROR)# project nameproject(recipe-07 LANGUAGES NONE)# detect pythonfind_package(PythonInterp REQUIRED)# define testsenable_testing()# we expect this test to run for 2 secondsadd_test(example ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py)
- In addition, we specify a TIMEOUT for the test, and set it to 10 seconds:
set_tests_properties(example PROPERTIES TIMEOUT 10)
- We know how to configure and build, and we expect the test to pass:
$ ctestTest project /home/user/cmake-recipes/chapter-04/recipe-07/example/build ...