summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/BuiltinTargets
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-09 16:55:49 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-10 18:19:08 (GMT)
commiteaa00d4dfa5ea7e611fc447d986bb10c41c7b0e1 (patch)
tree92e8c78c3bf3a14053832023a61374c4d21f0f5a /Tests/RunCMake/BuiltinTargets
parentd6b796854bcb0460b7d3a8eee3e79a9482b6fc62 (diff)
downloadCMake-eaa00d4dfa5ea7e611fc447d986bb10c41c7b0e1.zip
CMake-eaa00d4dfa5ea7e611fc447d986bb10c41c7b0e1.tar.gz
CMake-eaa00d4dfa5ea7e611fc447d986bb10c41c7b0e1.tar.bz2
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.
Diffstat (limited to 'Tests/RunCMake/BuiltinTargets')
-rw-r--r--Tests/RunCMake/BuiltinTargets/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/BuiltinTargets/TestDependsAll-Default-build-check.cmake1
-rw-r--r--Tests/RunCMake/BuiltinTargets/TestDependsAll-Default.cmake1
-rw-r--r--Tests/RunCMake/BuiltinTargets/TestDependsAll-No-build-check.cmake3
-rw-r--r--Tests/RunCMake/BuiltinTargets/TestDependsAll-common.cmake3
6 files changed, 28 insertions, 0 deletions
diff --git a/Tests/RunCMake/BuiltinTargets/CMakeLists.txt b/Tests/RunCMake/BuiltinTargets/CMakeLists.txt
new file mode 100644
index 0000000..6a9ce76
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.28)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake b/Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake
new file mode 100644
index 0000000..9c58bae
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default-build-check.cmake b/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default-build-check.cmake
new file mode 100644
index 0000000..5ef321a
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default-build-check.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/TestDependsAll-No-build-check.cmake)
diff --git a/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default.cmake b/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default.cmake
new file mode 100644
index 0000000..6abd56c
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/TestDependsAll-Default.cmake
@@ -0,0 +1 @@
+include(TestDependsAll-common.cmake)
diff --git a/Tests/RunCMake/BuiltinTargets/TestDependsAll-No-build-check.cmake b/Tests/RunCMake/BuiltinTargets/TestDependsAll-No-build-check.cmake
new file mode 100644
index 0000000..f42244e
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/TestDependsAll-No-build-check.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()
diff --git a/Tests/RunCMake/BuiltinTargets/TestDependsAll-common.cmake b/Tests/RunCMake/BuiltinTargets/TestDependsAll-common.cmake
new file mode 100644
index 0000000..bbe7c75
--- /dev/null
+++ b/Tests/RunCMake/BuiltinTargets/TestDependsAll-common.cmake
@@ -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)