Tests: Migrate CTestTest{NoBuild,NoExe} to RunCMake.ctest_{build,test}

Avoid duplicating infrastructure provided by the latter.
This commit is contained in:
Brad King 2023-09-07 11:00:58 -04:00
parent 1c5e4b60b1
commit be657bf1e0
15 changed files with 38 additions and 94 deletions

View File

@ -2765,29 +2765,6 @@ if(BUILD_TESTING)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
endif()
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
@ONLY ESCAPE_QUOTES)
add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
)
set_tests_properties(CTestTestNoBuild PROPERTIES
FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
@ONLY ESCAPE_QUOTES)
add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
)
set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
PASS_REGULAR_EXPRESSION "Could not find executable"
FAIL_REGULAR_EXPRESSION "SegFault")
if(NOT CMake_TEST_NO_NETWORK)
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"

View File

@ -1,8 +0,0 @@
cmake_minimum_required (VERSION 3.5)
project(CTestTestFailure)
include(CTest)
add_executable (NoBuild badCode.cxx)
target_link_libraries (NoBuild ${EXTRA_LIBS})
add_test (TestNoExe NoBuild)

View File

@ -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")

View File

@ -1,23 +0,0 @@
cmake_minimum_required(VERSION 3.5)
# Settings:
set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest")
set(CTEST_SITE "@SITE@")
set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
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})
CTEST_START(Experimental)
#CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res)
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)

View File

@ -1,21 +0,0 @@
cmake_minimum_required(VERSION 3.5)
# Settings:
set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest")
set(CTEST_SITE "@SITE@")
set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
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})
CTEST_START(Experimental)
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)

View File

@ -472,7 +472,7 @@ add_test(test1 \"${CMAKE_COMMAND}\" -E false)
add_test(test2 \"${CMAKE_COMMAND}\" -E echo \"hello world\")
add_test(test3 \"${CMAKE_COMMAND}\" -E true)
set_tests_properties(test3 PROPERTIES DISABLED \"ON\")
add_test(test4 \"${CMAKE_COMMAND}/doesnt_exist\")
add_test(test4 \"${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist\")
add_test(test5 \"${CMAKE_COMMAND}\" -E echo \"please skip\")
set_tests_properties(test5 PROPERTIES SKIP_REGULAR_EXPRESSION \"please skip\")
")

View File

@ -1 +1,2 @@
Unable to find executable: .*doesnt_exist
Unable to find executable:[^
]*does_not_exist

View File

@ -13,18 +13,18 @@ endfunction()
run_ctest_build(BuildQuiet QUIET)
run_ctest_build(ParallelLevel PARALLEL_LEVEL 1)
function(run_BuildFailure)
set(CASE_CMAKELISTS_SUFFIX_CODE [[
add_custom_target(BuildFailure ALL COMMAND command-does-not-exist)
]])
block()
set(LANG CXX)
configure_file("${RunCMake_SOURCE_DIR}/BuildFailure.cxx" "${RunCMake_BINARY_DIR}/BuildFailure/BuildFailure.cxx" COPYONLY)
set(CASE_CMAKELISTS_SUFFIX_CODE [=[
add_executable(BuildFailure BuildFailure.cxx)
]=])
set(CASE_CMAKELISTS_PREFIX_CODE [[
if(NOT CTEST_USE_LAUNCHERS)
message(FATAL_ERROR "CTEST_USE_LAUNCHERS not set")
endif()
]])
set(CASE_TEST_PREFIX_CODE [[
cmake_policy(SET CMP0061 NEW)
]])
set(CASE_TEST_PREFIX_CODE "")
set(CASE_TEST_SUFFIX_CODE [[
if (ctest_build_return_value)
message("ctest_build returned non-zero")
@ -35,13 +35,16 @@ endif()
run_ctest(BuildFailure)
if (RunCMake_GENERATOR MATCHES "Makefiles")
set(LANG NONE)
set(CASE_TEST_PREFIX_CODE [[
cmake_policy(VERSION 3.2)
]])
set(CASE_CMAKELISTS_SUFFIX_CODE [[
add_custom_target(BuildFailure ALL COMMAND command-does-not-exist)
]])
run_ctest(BuildFailure-CMP0061-OLD)
endif()
endfunction()
run_BuildFailure()
endblock()
function(run_BuildChangeId)
set(CASE_TEST_PREFIX_CODE [[

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
.*Unable to find executable[^
]*does_not_exist

View File

@ -0,0 +1,7 @@
.*Could not find executable[^
]*does_not_exist
.*
50% tests passed, 1 tests failed out of 2
.*
The following tests FAILED:
.*testNotRun \(Not Run\)

View File

@ -53,6 +53,13 @@ unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
unset(CASE_CTEST_TEST_LOAD)
unset(RunCTest_VERBOSE_FLAG)
block()
set(CASE_CMAKELISTS_SUFFIX_CODE [[
add_test(NAME testNotRun COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist)
]])
run_ctest_test(NotRun)
endblock()
function(run_TestChangeId)
set(CASE_TEST_PREFIX_CODE [[
set(CTEST_CHANGE_ID "<>1")
@ -131,8 +138,7 @@ run_TestRepeat(AfterTimeout RETURN_VALUE:0 REPEAT AFTER_TIMEOUT:3)
# test repeat and not run tests interact correctly
set(CASE_CMAKELISTS_SUFFIX_CODE [[
add_test(NAME testNotRun
COMMAND ${CMAKE_COMMAND}/doesnt_exist)
add_test(NAME testNotRun COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist)
set_property(TEST testNotRun PROPERTY TIMEOUT 5)
]])
run_TestRepeat(NotRun RETURN_VALUE:1 REPEAT UNTIL_PASS:3)

View File

@ -1 +1,2 @@
.*Unable to find executable.*
.*Unable to find executable[^
]*does_not_exist

View File

@ -1,5 +1,7 @@
.*Could not find executable[^
]*does_not_exist
.*
50% tests passed, 1 tests failed out of 2
.*
The following tests FAILED:
.*testNotRun.*Not Run.*
.*testNotRun \(Not Run\)