mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
Tests: Add RunCMake.CTestTimeout test
This test will consolidate CTest timeout-related tests.
This commit is contained in:
@@ -349,6 +349,7 @@ add_RunCMake_test(alias_targets)
|
||||
add_RunCMake_test(interface_library)
|
||||
add_RunCMake_test(no_install_prefix)
|
||||
add_RunCMake_test(configure_file)
|
||||
add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME})
|
||||
add_RunCMake_test(CTestTimeoutAfterMatch)
|
||||
|
||||
# ctresalloc links against CMakeLib and CTestLib, which means it can't be built
|
||||
|
||||
6
Tests/RunCMake/CTestTimeout/Basic-stdout.txt
Normal file
6
Tests/RunCMake/CTestTimeout/Basic-stdout.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Test project [^
|
||||
]*/Tests/RunCMake/CTestTimeout/Basic-build
|
||||
Start 1: TestTimeout
|
||||
1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[0-9.]+ sec
|
||||
+
|
||||
0% tests passed, 1 tests failed out of 1
|
||||
15
Tests/RunCMake/CTestTimeout/CMakeLists.txt.in
Normal file
15
Tests/RunCMake/CTestTimeout/CMakeLists.txt.in
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(CTestTest@CASE_NAME@ C)
|
||||
include(CTest)
|
||||
|
||||
add_executable(TestTimeout TestTimeout.c)
|
||||
|
||||
if(NOT TIMEOUT)
|
||||
set(TIMEOUT 4)
|
||||
endif()
|
||||
target_compile_definitions(TestTimeout PRIVATE TIMEOUT=${TIMEOUT})
|
||||
|
||||
add_test(NAME TestTimeout COMMAND TestTimeout)
|
||||
set_property(TEST TestTimeout PROPERTY TIMEOUT ${TIMEOUT})
|
||||
|
||||
@CASE_CMAKELISTS_SUFFIX_CODE@
|
||||
14
Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake
Normal file
14
Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake
Normal file
@@ -0,0 +1,14 @@
|
||||
include(RunCTest)
|
||||
|
||||
if(NOT TIMEOUT)
|
||||
# Give the process time to load and start running.
|
||||
set(TIMEOUT 4)
|
||||
endif()
|
||||
|
||||
function(run_ctest_timeout CASE_NAME)
|
||||
configure_file(${RunCMake_SOURCE_DIR}/TestTimeout.c
|
||||
${RunCMake_BINARY_DIR}/${CASE_NAME}/TestTimeout.c COPYONLY)
|
||||
run_ctest(${CASE_NAME})
|
||||
endfunction()
|
||||
|
||||
run_ctest_timeout(Basic)
|
||||
17
Tests/RunCMake/CTestTimeout/TestTimeout.c
Normal file
17
Tests/RunCMake/CTestTimeout/TestTimeout.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep((TIMEOUT + 4) * 1000);
|
||||
#else
|
||||
sleep((TIMEOUT + 4));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
16
Tests/RunCMake/CTestTimeout/test.cmake.in
Normal file
16
Tests/RunCMake/CTestTimeout/test.cmake.in
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
@CASE_TEST_PREFIX_CODE@
|
||||
|
||||
set(CTEST_SITE "test-site")
|
||||
set(CTEST_BUILD_NAME "test-build-name")
|
||||
set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
|
||||
set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
|
||||
set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
|
||||
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
|
||||
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
|
||||
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
|
||||
|
||||
ctest_start(Experimental)
|
||||
ctest_configure(OPTIONS "-DTIMEOUT=@TIMEOUT@")
|
||||
ctest_build()
|
||||
ctest_test()
|
||||
Reference in New Issue
Block a user