Commit b513a879 authored by Marc Chevrier's avatar Marc Chevrier
Browse files

Tests management: add TESTS directory property

Implements: #17680
parent 1da3f3e9
......@@ -84,6 +84,7 @@ Properties on Directories
/prop_dir/RULE_LAUNCH_LINK
/prop_dir/SOURCE_DIR
/prop_dir/SUBDIRECTORIES
/prop_dir/TESTS
/prop_dir/TEST_INCLUDE_FILES
/prop_dir/VARIABLES
/prop_dir/VS_GLOBAL_SECTION_POST_section
......
TESTS
-----
List of tests.
This read-only property holds a :ref:`;-list <CMake Language Lists>` of tests
defined so far by the :command:`add_test` command.
directory-property-TESTS
------------------------
* The :prop_dir:`TESTS` directory property was added to hold the list of tests defined by
command :command:`add_test`.
......@@ -3641,6 +3641,20 @@ void cmMakefile::AppendProperty(const std::string& prop, const char* value,
const char* cmMakefile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
static std::string output;
if (prop == "TESTS") {
std::vector<std::string> keys;
// get list of keys
std::transform(this->Tests.begin(), this->Tests.end(),
std::back_inserter(keys),
[](decltype(this->Tests)::value_type const& pair) {
return pair.first;
});
output = cmJoin(keys, ";");
return output.c_str();
}
return this->StateSnapshot.GetDirectory().GetProperty(prop);
}
......
......@@ -19,4 +19,12 @@ get_property: -->[^<;]*/Tests/RunCMake/get_property<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--$
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--
get_directory_property: --><--
get_property: --><--
get_directory_property: -->test1;test2<--
get_property: -->test1;test2<--
get_directory_property: -->test1;test2;test3<--
get_property: -->test1;test2;test3<--
get_directory_property: -->Sub/test1;Sub/test2<--
get_property: -->Sub/test1;Sub/test2<--$
......@@ -28,3 +28,12 @@ check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SOURCE_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
add_test(NAME test1 COMMAND "${CMAKE_COMMAND}" -E echo "test1")
add_test(NAME test2 COMMAND "${CMAKE_COMMAND}" -E echo "test2")
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
add_test(NAME test3 COMMAND "${CMAKE_COMMAND}" -E echo "test3")
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" TESTS)
......@@ -4,3 +4,6 @@ subdirs(sub2)
add_custom_target(CustomSub)
add_library(InterfaceSub INTERFACE)
add_library(my::InterfaceSub ALIAS InterfaceSub)
add_test(Sub/test1 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test1")
add_test(Sub/test2 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test2")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment