mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
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:
3
Tests/RunCMake/BuiltinTargets/CMakeLists.txt
Normal file
3
Tests/RunCMake/BuiltinTargets/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
17
Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake
Normal file
17
Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake
Normal 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)
|
||||
@@ -0,0 +1 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TestDependsAll-No-build-check.cmake)
|
||||
@@ -0,0 +1 @@
|
||||
include(TestDependsAll-common.cmake)
|
||||
@@ -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()
|
||||
@@ -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)
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user