Tests: Add case to verify that 'make test' does not 'make all'

Place it in a new `RunCMake.BuiltinTargets` umbrella test meant to cover
behavior of targets builtin to CMake.
This commit is contained in:
Brad King
2023-11-09 11:55:49 -05:00
parent d6b796854b
commit eaa00d4dfa
7 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.28)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,17 @@
include(RunCMake)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
set(test_target "test")
else()
set(test_target "RUN_TESTS")
endif()
function(run_BuiltinTarget case target)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
run_cmake(${case})
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug --target ${${target}_target})
endfunction()
run_BuiltinTarget(TestDependsAll-Default test)

View File

@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/TestDependsAll-No-build-check.cmake)

View File

@@ -0,0 +1 @@
include(TestDependsAll-common.cmake)

View File

@@ -0,0 +1,3 @@
if(EXISTS ${RunCMake_TEST_BINARY_DIR}/custom-output.txt)
set(RunCMake_TEST_FAILED "Building 'test' target incorrectly built 'all' target.")
endif()

View File

@@ -0,0 +1,3 @@
enable_testing()
add_custom_target(custom ALL COMMAND ${CMAKE_COMMAND} -E touch custom-output.txt)
add_test(NAME test COMMAND ${CMAKE_COMMAND} -E echo)

View File

@@ -322,6 +322,7 @@ add_RunCMake_test(BuildDepends
-DCMAKE_C_LINK_DEPENDS_USE_COMPILER=${CMAKE_C_LINK_DEPENDS_USE_COMPILER}
-DCMake_TEST_BuildDepends_GNU_AS=${CMake_TEST_BuildDepends_GNU_AS}
)
add_RunCMake_test(BuiltinTargets)
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(Byproducts)
endif()