summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-08-14 15:18:04 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-08-14 15:18:54 (GMT)
commit2eab65ca828084559e1019bd1263c5ab147bf135 (patch)
tree3fde898ff573722bbbe2f23cdb3a7c542b30e74a /Tests
parent0d95b68bd807ccc4eee44619da29974caf3a1a1b (diff)
parent2ccb897d86598daa983f77ce764411c5723b568c (diff)
downloadCMake-2eab65ca828084559e1019bd1263c5ab147bf135.zip
CMake-2eab65ca828084559e1019bd1263c5ab147bf135.tar.gz
CMake-2eab65ca828084559e1019bd1263c5ab147bf135.tar.bz2
Merge topic 'test-properties-directory'
2ccb897d86 get_test_property(): Add DIRECTORY option 84e76fedb0 get_property(TEST): Add DIRECTORY option efc8f19cc5 set_tests_properties(): Add DIRECTORY option 753999d4db set_property(TEST): Add DIRECTORY option Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8709
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/get_property/test_properties-stderr.txt10
-rw-r--r--Tests/RunCMake/get_property/test_properties.cmake19
-rw-r--r--Tests/RunCMake/get_property/test_properties/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/set_property/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/set_property/TEST-invalid-result.txt1
-rw-r--r--Tests/RunCMake/set_property/TEST-invalid-stderr.txt11
-rw-r--r--Tests/RunCMake/set_property/TEST-invalid.cmake4
-rw-r--r--Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/set_property/TEST.cmake9
-rw-r--r--Tests/RunCMake/set_tests_properties/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt1
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt13
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake4
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/set_tests_properties/DIRECTORY.cmake9
-rw-r--r--Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake8
19 files changed, 103 insertions, 8 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index f8b84b2..8562e2b 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -1064,6 +1064,7 @@ add_RunCMake_test(CMakePresetsWorkflow
)
add_RunCMake_test(VerifyHeaderSets)
+add_RunCMake_test(set_tests_properties)
if(${CMAKE_GENERATOR} MATCHES "Make|Ninja")
add_RunCMake_test(TransformDepfile)
diff --git a/Tests/RunCMake/get_property/test_properties-stderr.txt b/Tests/RunCMake/get_property/test_properties-stderr.txt
index a447280..9f5a10f 100644
--- a/Tests/RunCMake/get_property/test_properties-stderr.txt
+++ b/Tests/RunCMake/get_property/test_properties-stderr.txt
@@ -1,6 +1,12 @@
-^get_test_property: --><--
+^get_test_property: -->value<--
+get_property: -->value<--
+get_test_property: --><--
get_property: --><--
get_test_property: -->value<--
get_property: -->value<--
get_test_property: -->NOTFOUND<--
-get_property: --><--$
+get_property: --><--
+get_test_property: -->anotherValue<--
+get_property: -->anotherValue<--
+get_test_property: -->anotherValue<--
+get_property: -->anotherValue<--$
diff --git a/Tests/RunCMake/get_property/test_properties.cmake b/Tests/RunCMake/get_property/test_properties.cmake
index 1d0295c..f1cbca4 100644
--- a/Tests/RunCMake/get_property/test_properties.cmake
+++ b/Tests/RunCMake/get_property/test_properties.cmake
@@ -1,7 +1,11 @@
-function (check_test_property test prop)
- get_test_property("${test}" "${prop}" gtp_val)
+function (check_test_property test prop dir)
+ set(dir_args)
+ if(dir)
+ set(dir_args DIRECTORY ${dir})
+ endif()
+ get_test_property("${test}" "${prop}" ${dir_args} gtp_val)
get_property(gp_val
- TEST "${test}"
+ TEST "${test}" ${dir_args}
PROPERTY "${prop}")
message("get_test_property: -->${gtp_val}<--")
@@ -11,7 +15,10 @@ endfunction ()
include(CTest)
add_test(NAME test COMMAND "${CMAKE_COMMAND}" --help)
set_tests_properties(test PROPERTIES empty "" custom value)
+add_subdirectory(test_properties)
-check_test_property(test empty)
-check_test_property(test custom)
-check_test_property(test noexist)
+check_test_property(test empty "")
+check_test_property(test custom "")
+check_test_property(test noexist "")
+check_test_property(test custom test_properties)
+check_test_property(test custom ${CMAKE_BINARY_DIR}/test_properties)
diff --git a/Tests/RunCMake/get_property/test_properties/CMakeLists.txt b/Tests/RunCMake/get_property/test_properties/CMakeLists.txt
new file mode 100644
index 0000000..ee90344
--- /dev/null
+++ b/Tests/RunCMake/get_property/test_properties/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_test(NAME test COMMAND "${CMAKE_COMMAND}" --help)
+set_tests_properties(test PROPERTIES empty "" custom anotherValue)
+
+check_test_property(test custom ..)
diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake
index 692c6b9..1a5498d 100644
--- a/Tests/RunCMake/set_property/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake
@@ -10,6 +10,12 @@ run_cmake(LINK_DIRECTORIES)
run_cmake(LINK_LIBRARIES)
run_cmake(SOURCES)
run_cmake(SOURCE_FILE)
+run_cmake(TEST-invalid)
run_cmake(TYPE)
run_cmake(USER_PROP)
run_cmake(USER_PROP_INHERITED)
+
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/TEST-build")
+run_cmake(TEST)
+set(RunCMake_TEST_NO_CLEAN 1)
+run_cmake_command(TEST-test ${CMAKE_CTEST_COMMAND} -C Debug)
diff --git a/Tests/RunCMake/set_property/TEST-invalid-result.txt b/Tests/RunCMake/set_property/TEST-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/set_property/TEST-invalid-stderr.txt b/Tests/RunCMake/set_property/TEST-invalid-stderr.txt
new file mode 100644
index 0000000..c0a40d6
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST-invalid-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Error at TEST-invalid\.cmake:[0-9]+ \(set_property\):
+ set_property called with incorrect number of arguments no value provided to
+ the DIRECTORY option
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at TEST-invalid\.cmake:[0-9]+ \(set_property\):
+ set_property given non-existent DIRECTORY nonexistent
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/set_property/TEST-invalid.cmake b/Tests/RunCMake/set_property/TEST-invalid.cmake
new file mode 100644
index 0000000..6828c96
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST-invalid.cmake
@@ -0,0 +1,4 @@
+enable_testing()
+
+set_property(TEST t DIRECTORY PROPERTY PASS_REGULAR_EXPRESSION "Invalid")
+set_property(TEST t DIRECTORY nonexistent PROPERTY PASS_REGULAR_EXPRESSION "Invalid")
diff --git a/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt b/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt
new file mode 100644
index 0000000..b1fad66
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
+add_test(NAME t2 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
+add_test(NAME t3 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
diff --git a/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt b/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt
new file mode 100644
index 0000000..8621b00
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt
@@ -0,0 +1 @@
+set_property(TEST t3 DIRECTORY ../TEST-subdir1 PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory")
diff --git a/Tests/RunCMake/set_property/TEST.cmake b/Tests/RunCMake/set_property/TEST.cmake
new file mode 100644
index 0000000..7ef5aa3
--- /dev/null
+++ b/Tests/RunCMake/set_property/TEST.cmake
@@ -0,0 +1,9 @@
+enable_testing()
+
+add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Top directory")
+add_subdirectory(TEST-subdir1)
+add_subdirectory(TEST-subdir2)
+
+set_property(TEST t PROPERTY PASS_REGULAR_EXPRESSION "Top directory")
+set_property(TEST t DIRECTORY TEST-subdir1 PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory")
+set_property(TEST t2 DIRECTORY "${CMAKE_BINARY_DIR}/TEST-subdir1" PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory")
diff --git a/Tests/RunCMake/set_tests_properties/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/CMakeLists.txt
new file mode 100644
index 0000000..922aad6
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.27)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt
new file mode 100644
index 0000000..e219399
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt
@@ -0,0 +1,13 @@
+^CMake Error at DIRECTORY-invalid\.cmake:[0-9]+ \(set_tests_properties\):
+ Error after keyword "DIRECTORY":
+
+ missing required value
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at DIRECTORY-invalid\.cmake:[0-9]+ \(set_tests_properties\):
+ set_tests_properties given non-existent DIRECTORY nonexistent
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake
new file mode 100644
index 0000000..4d87df1
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake
@@ -0,0 +1,4 @@
+enable_testing()
+
+set_tests_properties(t DIRECTORY PROPERTIES PASS_REGULAR_EXPRESSION "Top directory")
+set_tests_properties(t DIRECTORY nonexistent PROPERTIES PASS_REGULAR_EXPRESSION "Top directory")
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt
new file mode 100644
index 0000000..b1fad66
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
+add_test(NAME t2 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
+add_test(NAME t3 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory")
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt
new file mode 100644
index 0000000..8859597
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt
@@ -0,0 +1 @@
+set_tests_properties(t3 DIRECTORY ../DIRECTORY-subdir1 PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory")
diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake b/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake
new file mode 100644
index 0000000..87d13e3
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake
@@ -0,0 +1,9 @@
+enable_testing()
+
+add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Top directory")
+add_subdirectory(DIRECTORY-subdir1)
+add_subdirectory(DIRECTORY-subdir2)
+
+set_tests_properties(t PROPERTIES PASS_REGULAR_EXPRESSION "Top directory")
+set_tests_properties(t DIRECTORY DIRECTORY-subdir1 PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory")
+set_tests_properties(t2 DIRECTORY "${CMAKE_BINARY_DIR}/DIRECTORY-subdir1" PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory")
diff --git a/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake b/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake
new file mode 100644
index 0000000..b49158f
--- /dev/null
+++ b/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(DIRECTORY-invalid)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DIRECTORY-build)
+run_cmake(DIRECTORY)
+set(RunCMake_TEST_NO_CLEAN 1)
+run_cmake_command(DIRECTORY-test ${CMAKE_CTEST_COMMAND} -C Debug)