Tests: Move CTest.BuildCommand.ProjectInSubdir into RunCMake.ctest_build

The former duplicates code that is now part of the infrastructure in the
latter.  The latter can also explicitly verify the results.
This commit is contained in:
Brad King
2022-02-04 08:34:09 -05:00
parent ca4bb89f27
commit e485dca1e8
4 changed files with 16 additions and 29 deletions

View File

@@ -2562,24 +2562,6 @@ if(BUILD_TESTING)
# -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
# )
# A test for ctest_build() with targets in subdirectories
set(ctest_configure_options)
if(CMAKE_GENERATOR_PLATFORM)
list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM})
endif()
if(CMAKE_GENERATOR_TOOLSET)
list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
endif()
if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
endif()
configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
unset(ctest_configure_options)
add_test(CTest.BuildCommand.ProjectInSubdir
${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
set(CTEST_TEST_UPDATE 1)
if(CTEST_TEST_UPDATE)
# Test CTest Update with Subversion

View File

@@ -1,11 +0,0 @@
cmake_minimum_required(VERSION 2.8.10)
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
ctest_start(Experimental)
ctest_configure(OPTIONS "@ctest_configure_options@")
ctest_build(TARGET test)

View File

@@ -49,6 +49,18 @@ function(run_BuildChangeId)
endfunction()
run_BuildChangeId()
function(run_SubdirTarget)
set(CASE_CMAKELISTS_SUFFIX_CODE [=[
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/subdir/CMakeLists.txt [[
add_custom_target(target_in_subdir COMMAND ${CMAKE_COMMAND} -E touch target_in_subdir.out VERBATIM)
]])
add_subdirectory(subdir)
]=])
set(CASE_CTEST_BUILD_ARGS TARGET target_in_subdir)
run_ctest(SubdirTarget)
endfunction()
run_SubdirTarget()
set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE)
set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}")
run_ctest(BuildCommandFailure)

View File

@@ -0,0 +1,4 @@
set(expected_file "${RunCMake_TEST_BINARY_DIR}/subdir/target_in_subdir.out")
if(NOT EXISTS "${expected_file}")
set(RunCMake_TEST_FAILED "Expected build output file not found:\n ${expected_file}")
endif()