mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-07 07:39:32 -06:00
Merge topic 'test-cleanup'
4a67306ddbTests: Remove redundant CTestTestTimeout test8f848dbc1fTests/RunCMake/CTestCommandLine: Add case for ctest --rerun-failed Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !11490
This commit is contained in:
@@ -3035,25 +3035,6 @@ if(BUILD_TESTING)
|
||||
set_tests_properties(CTestTestSubdir PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
|
||||
|
||||
configure_file(
|
||||
"${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
|
||||
"${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
|
||||
@ONLY ESCAPE_QUOTES)
|
||||
add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
|
||||
-C "\${CTestTest_CONFIG}"
|
||||
-S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
|
||||
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
|
||||
)
|
||||
set_tests_properties(CTestTestTimeout PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
|
||||
|
||||
add_test(
|
||||
NAME CTestTestRerunFailed
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
|
||||
set_tests_properties(CTestTestRerunFailed PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
|
||||
WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
|
||||
|
||||
configure_file(
|
||||
"${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
|
||||
"${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(CTestTestTimeout)
|
||||
include(CTest)
|
||||
|
||||
if(NOT TIMEOUT)
|
||||
# Give the process time to load and start running.
|
||||
set(TIMEOUT 4)
|
||||
endif()
|
||||
|
||||
add_definitions(-DTIMEOUT=${TIMEOUT})
|
||||
add_executable (Sleep sleep.c)
|
||||
|
||||
add_test(NAME TestTimeout
|
||||
COMMAND ${CMAKE_COMMAND} -D Sleep=$<TARGET_FILE:Sleep>
|
||||
-D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake
|
||||
)
|
||||
set_tests_properties(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT})
|
||||
|
||||
add_test(NAME TestSleep COMMAND Sleep)
|
||||
set_tests_properties(TestSleep PROPERTIES DEPENDS TestTimeout)
|
||||
@@ -1,4 +0,0 @@
|
||||
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
|
||||
set(CTEST_DROP_METHOD "http")
|
||||
set(CTEST_DROP_SITE "open.cdash.org")
|
||||
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
|
||||
@@ -1,21 +0,0 @@
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "before sleep\n");
|
||||
fflush(stderr); /* should not be needed, but just in case */
|
||||
#if defined(_WIN32)
|
||||
Sleep((TIMEOUT + 4) * 1000);
|
||||
#else
|
||||
sleep((TIMEOUT + 4));
|
||||
#endif
|
||||
fprintf(stderr, "after sleep\n");
|
||||
fflush(stderr); /* should not be needed, but just in case */
|
||||
return 0;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# Settings:
|
||||
set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest")
|
||||
set(CTEST_SITE "@SITE@")
|
||||
set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout")
|
||||
|
||||
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout")
|
||||
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout")
|
||||
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
|
||||
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
|
||||
set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@")
|
||||
set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
|
||||
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
|
||||
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
|
||||
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
|
||||
|
||||
#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY})
|
||||
|
||||
file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "
|
||||
TIMEOUT:STRING=@CTestTestTimeout_TIME@
|
||||
")
|
||||
|
||||
CTEST_START(Experimental)
|
||||
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
|
||||
set(log ${CTEST_BINARY_DIRECTORY}/timeout.log)
|
||||
if(EXISTS "${log}")
|
||||
# Verify that the timeout test did not finish sleeping.
|
||||
file(STRINGS "${log}" after_sleep REGEX "after sleep")
|
||||
if(after_sleep)
|
||||
message(FATAL_ERROR "Log indicates timeout did not kill child.")
|
||||
else()
|
||||
message(STATUS "Log indicates timeout correctly killed child.")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Log does not exist:\n ${log}")
|
||||
endif()
|
||||
@@ -1,6 +0,0 @@
|
||||
# Remove the log file.
|
||||
file(REMOVE ${Log})
|
||||
|
||||
# Run a child that sleeps longer than the timeout of this test.
|
||||
# Log its output so check.cmake can verify it dies.
|
||||
execute_process(COMMAND ${Sleep} ERROR_FILE ${Log})
|
||||
@@ -104,6 +104,19 @@ endfunction()
|
||||
run_repeat_until_fail_tests(--repeat-until-fail 3)
|
||||
run_repeat_until_fail_tests(--repeat until-fail:3)
|
||||
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/rerun)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
|
||||
add_test(works \"${CMAKE_COMMAND}\" -E true)
|
||||
add_test(fails \"${CMAKE_COMMAND}\" -E false)
|
||||
")
|
||||
run_cmake_command(rerun-init ${CMAKE_CTEST_COMMAND})
|
||||
run_cmake_command(rerun-failed ${CMAKE_CTEST_COMMAND} --rerun-failed)
|
||||
endblock()
|
||||
|
||||
function(run_BadCTestTestfile)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BadCTestTestfile)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
|
||||
1
Tests/RunCMake/CTestCommandLine/rerun-failed-result.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/rerun-failed-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
[^0]
|
||||
1
Tests/RunCMake/CTestCommandLine/rerun-failed-stderr.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/rerun-failed-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
.*
|
||||
11
Tests/RunCMake/CTestCommandLine/rerun-failed-stdout.txt
Normal file
11
Tests/RunCMake/CTestCommandLine/rerun-failed-stdout.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
^Test project [^
|
||||
]*/Tests/RunCMake/CTestCommandLine/rerun
|
||||
Start 2: fails
|
||||
1/1 Test #2: fails \.+\*\*\*Failed +[0-9\.]+ sec
|
||||
+
|
||||
0% tests passed, 1 tests failed out of 1
|
||||
+
|
||||
Total Test time \(real\) = +[0-9\.]+ sec
|
||||
+
|
||||
The following tests FAILED:
|
||||
[ ]+2 - fails \(Failed\)$
|
||||
1
Tests/RunCMake/CTestCommandLine/rerun-init-result.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/rerun-init-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
[^0]
|
||||
1
Tests/RunCMake/CTestCommandLine/rerun-init-stderr.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/rerun-init-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
.*
|
||||
13
Tests/RunCMake/CTestCommandLine/rerun-init-stdout.txt
Normal file
13
Tests/RunCMake/CTestCommandLine/rerun-init-stdout.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
^Test project [^
|
||||
]*/Tests/RunCMake/CTestCommandLine/rerun
|
||||
Start 1: works
|
||||
1/2 Test #1: works \.+ Passed +[0-9\.]+ sec
|
||||
Start 2: fails
|
||||
2/2 Test #2: fails \.+\*\*\*Failed +[0-9\.]+ sec
|
||||
+
|
||||
50% tests passed, 1 tests failed out of 2
|
||||
+
|
||||
Total Test time \(real\) = +[0-9\.]+ sec
|
||||
+
|
||||
The following tests FAILED:
|
||||
[ ]+2 - fails \(Failed\)$
|
||||
Reference in New Issue
Block a user