diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-08-14 15:18:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-08-14 15:18:54 (GMT) |
commit | 2eab65ca828084559e1019bd1263c5ab147bf135 (patch) | |
tree | 3fde898ff573722bbbe2f23cdb3a7c542b30e74a | |
parent | 0d95b68bd807ccc4eee44619da29974caf3a1a1b (diff) | |
parent | 2ccb897d86598daa983f77ce764411c5723b568c (diff) | |
download | CMake-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
29 files changed, 333 insertions, 30 deletions
diff --git a/Help/command/get_property.rst b/Help/command/get_property.rst index 6b9931e..a0a12bb 100644 --- a/Help/command/get_property.rst +++ b/Help/command/get_property.rst @@ -12,7 +12,8 @@ Get a property. SOURCE <source> [DIRECTORY <dir> | TARGET_DIRECTORY <target>] | INSTALL <file> | - TEST <test> | + TEST <test> + [DIRECTORY <dir>] | CACHE <entry> | VARIABLE > PROPERTY <name> @@ -73,6 +74,16 @@ It must be one of the following: Scope must name one existing test. See also the :command:`get_test_property` command. + .. versionadded:: 3.28 + Directory scope can be overridden with the following sub-option: + + ``DIRECTORY <dir>`` + The test property will be read from the ``<dir>`` directory's + scope. CMake must already know about the directory, either by having added + it through a call to :command:`add_subdirectory` or ``<dir>`` being the top + level directory. Relative paths are treated as relative to the current + source directory. ``<dir>`` may reference a binary directory. + ``CACHE`` Scope must name one cache entry. diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst index 2b6f354..1fcf24e 100644 --- a/Help/command/get_test_property.rst +++ b/Help/command/get_test_property.rst @@ -5,7 +5,7 @@ Get a property of the test. .. code-block:: cmake - get_test_property(test property VAR) + get_test_property(test property [DIRECTORY <dir>] VAR) Get a property from the test. The value of the property is stored in the variable ``VAR``. If the test property is not found, the behavior @@ -19,6 +19,17 @@ an empty string. For a list of standard properties you can type :option:`cmake --help-property-list`. +.. versionadded:: 3.28 + Directory scope can be overridden with the following sub-option: + + ``DIRECTORY <dir>`` + The test property will be read from the ``<dir>`` directory's + scope. CMake must already know about that source directory, either by + having added it through a call to :command:`add_subdirectory` or ``<dir>`` + being the top level source directory. Relative paths are treated as + relative to the current source directory. ``<dir>`` may reference a binary + directory. + See Also ^^^^^^^^ diff --git a/Help/command/set_property.rst b/Help/command/set_property.rst index fc43974..f14b63d 100644 --- a/Help/command/set_property.rst +++ b/Help/command/set_property.rst @@ -12,7 +12,8 @@ Set a named property in a given scope. [DIRECTORY <dirs> ...] [TARGET_DIRECTORY <targets> ...] | INSTALL [<file1> ...] | - TEST [<test1> ...] | + TEST [<test1> ...] + [DIRECTORY <dir>] | CACHE [<entry1> ...] > [APPEND] [APPEND_STRING] PROPERTY <name> [<value1> ...]) @@ -91,6 +92,17 @@ It must be one of the following: :manual:`generator expressions <cmake-generator-expressions(7)>` for tests created by the :command:`add_test(NAME)` signature. + .. versionadded:: 3.28 + + Visibility can be set in other directory scopes using the following sub-option: + + ``DIRECTORY <dir>`` + The test property will be set in the ``<dir>`` directory's scope. CMake must + already know about this directory, either by having added it through a call + to :command:`add_subdirectory` or it being the top level source directory. + Relative paths are treated as relative to the current source directory. + ``<dir>`` may reference a binary directory. + ``CACHE`` Scope must name zero or more existing cache entries. diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index 1df9d73..da750e3 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst @@ -14,6 +14,16 @@ Test property values may be specified using :manual:`generator expressions <cmake-generator-expressions(7)>` for tests created by the :command:`add_test(NAME)` signature. +.. versionadded:: 3.28 + Visibility can be set in other directory scopes using the following option: + + ``DIRECTORY <dir>`` + The test properties will be set in the ``<dir>`` directory's scope. + CMake must already know about this directory, either by having added it + through a call to :command:`add_subdirectory` or it being the top level + source directory. Relative paths are treated as relative to the current + source directory. ``<dir>`` may reference a binary directory. + See Also ^^^^^^^^ diff --git a/Help/release/dev/test-properties-directory.rst b/Help/release/dev/test-properties-directory.rst new file mode 100644 index 0000000..9df7051 --- /dev/null +++ b/Help/release/dev/test-properties-directory.rst @@ -0,0 +1,15 @@ +test-properties-directory +------------------------- + +* The ``TEST`` mode of the :command:`set_property` command gained a + ``DIRECTORY`` sub-option, which allows you to set properties on tests in + other directories. +* The :command:`set_tests_properties` command gained a ``DIRECTORY`` + sub-option, which allows you to set properties on tests in other + directories. +* The ``TEST`` mode of the :command:`get_property` command gained a + ``DIRECTORY`` sub-option, which allows you to get properties on tests in + other directories. +* The :command:`get_test_property` command gained a ``DIRECTORY`` + sub-option, which allows you to get properties on tests in other + directories. diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 943ce1d..880756d 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -49,7 +49,8 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name, bool source_file_paths_should_be_absolute); bool HandleTestMode(cmExecutionStatus& status, const std::string& name, OutType infoType, const std::string& variable, - const std::string& propertyName); + const std::string& propertyName, + cmMakefile& directory_makefile); bool HandleVariableMode(cmExecutionStatus& status, const std::string& name, OutType infoType, const std::string& variable, const std::string& propertyName); @@ -81,6 +82,9 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, bool source_file_directory_option_enabled = false; bool source_file_target_option_enabled = false; + std::string test_directory; + bool test_directory_option_enabled = false; + // Get the scope from which to get the property. cmProperty::ScopeType scope; if (args[1] == "GLOBAL") { @@ -116,7 +120,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, DoingProperty, DoingType, DoingSourceDirectory, - DoingSourceTargetDirectory + DoingSourceTargetDirectory, + DoingTestDirectory, }; Doing doing = DoingName; for (unsigned int i = 2; i < args.size(); ++i) { @@ -145,12 +150,19 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, args[i] == "TARGET_DIRECTORY") { doing = DoingSourceTargetDirectory; source_file_target_option_enabled = true; + } else if (doing == DoingNone && scope == cmProperty::TEST && + args[i] == "DIRECTORY") { + doing = DoingTestDirectory; + test_directory_option_enabled = true; } else if (doing == DoingSourceDirectory) { source_file_directories.push_back(args[i]); doing = DoingNone; } else if (doing == DoingSourceTargetDirectory) { source_file_target_directories.push_back(args[i]); doing = DoingNone; + } else if (doing == DoingTestDirectory) { + test_directory = args[i]; + doing = DoingNone; } else if (doing == DoingProperty) { doing = DoingNone; propertyName = args[i]; @@ -167,12 +179,17 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, } std::vector<cmMakefile*> source_file_directory_makefiles; - bool file_scopes_handled = + bool source_file_scopes_handled = SetPropertyCommand::HandleAndValidateSourceFileDirectoryScopes( status, source_file_directory_option_enabled, source_file_target_option_enabled, source_file_directories, source_file_target_directories, source_file_directory_makefiles); - if (!file_scopes_handled) { + cmMakefile* test_directory_makefile; + bool test_scopes_handled = + SetPropertyCommand::HandleAndValidateTestDirectoryScopes( + status, test_directory_option_enabled, test_directory, + test_directory_makefile); + if (!(source_file_scopes_handled && test_scopes_handled)) { return false; } @@ -231,7 +248,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, directory_scope_mf, source_file_paths_should_be_absolute); case cmProperty::TEST: - return HandleTestMode(status, name, infoType, variable, propertyName); + return HandleTestMode(status, name, infoType, variable, propertyName, + *test_directory_makefile); case cmProperty::VARIABLE: return HandleVariableMode(status, name, infoType, variable, propertyName); @@ -404,7 +422,7 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name, bool HandleTestMode(cmExecutionStatus& status, const std::string& name, OutType infoType, const std::string& variable, - const std::string& propertyName) + const std::string& propertyName, cmMakefile& test_makefile) { if (name.empty()) { status.SetError("not given name for TEST scope."); @@ -412,7 +430,7 @@ bool HandleTestMode(cmExecutionStatus& status, const std::string& name, } // Loop over all tests looking for matching names. - if (cmTest* test = status.GetMakefile().GetTest(name)) { + if (cmTest* test = test_makefile.GetTest(name)) { return StoreResult(infoType, status.GetMakefile(), variable, test->GetProperty(propertyName)); } diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index 36446c9..103471b 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -4,21 +4,42 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmSetPropertyCommand.h" #include "cmTest.h" #include "cmValue.h" bool cmGetTestPropertyCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { - if (args.size() < 3) { + std::vector<std::string>::size_type args_size = args.size(); + if (args_size != 3 && args_size != 5) { status.SetError("called with incorrect number of arguments"); return false; } + std::string test_directory; + bool test_directory_option_enabled = false; + + int var_arg_index = 2; + if (args[2] == "DIRECTORY" && args_size == 5) { + var_arg_index = 4; + test_directory_option_enabled = true; + test_directory = args[3]; + } + + cmMakefile* test_directory_makefile = &status.GetMakefile(); + bool file_scopes_handled = + SetPropertyCommand::HandleAndValidateTestDirectoryScopes( + status, test_directory_option_enabled, test_directory, + test_directory_makefile); + if (!file_scopes_handled) { + return false; + } + std::string const& testName = args[0]; - std::string const& var = args[2]; + std::string const& var = args[var_arg_index]; cmMakefile& mf = status.GetMakefile(); - cmTest* test = mf.GetTest(testName); + cmTest* test = test_directory_makefile->GetTest(testName); if (test) { cmValue prop; if (!args[1].empty()) { diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index de1e3b0..f9afed8 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -58,7 +58,8 @@ bool HandleSource(cmSourceFile* sf, const std::string& propertyName, bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names, const std::string& propertyName, const std::string& propertyValue, bool appendAsString, - bool appendMode, bool remove); + bool appendMode, bool remove, + cmMakefile* test_directory_makefile); bool HandleTest(cmTest* test, const std::string& propertyName, const std::string& propertyValue, bool appendAsString, bool appendMode, bool remove); @@ -184,6 +185,60 @@ bool HandleAndValidateSourceFileDirectoryScopes( return scope_options_valid; } +bool HandleTestDirectoryScopes(cmExecutionStatus& status, + std::string& test_directory, + cmMakefile*& directory_makefile) +{ + cmMakefile* current_dir_mf = &status.GetMakefile(); + if (!test_directory.empty()) { + const std::string absolute_dir_path = cmSystemTools::CollapseFullPath( + test_directory, current_dir_mf->GetCurrentSourceDirectory()); + cmMakefile* dir_mf = + status.GetMakefile().GetGlobalGenerator()->FindMakefile( + absolute_dir_path); + if (!dir_mf) { + status.SetError( + cmStrCat("given non-existent DIRECTORY ", test_directory)); + return false; + } + directory_makefile = dir_mf; + } else { + directory_makefile = current_dir_mf; + } + return true; +} + +bool HandleTestDirectoryScopeValidation(cmExecutionStatus& status, + bool test_directory_option_enabled, + std::string& test_directory) +{ + // Validate source file directory scopes. + if (test_directory_option_enabled && test_directory.empty()) { + std::string errors = "called with incorrect number of arguments " + "no value provided to the DIRECTORY option"; + status.SetError(errors); + return false; + } + return true; +} + +bool HandleAndValidateTestDirectoryScopes(cmExecutionStatus& status, + bool test_directory_option_enabled, + std::string& test_directory, + cmMakefile*& test_directory_makefile) +{ + bool scope_options_valid = + SetPropertyCommand::HandleTestDirectoryScopeValidation( + status, test_directory_option_enabled, test_directory); + if (!scope_options_valid) { + return false; + } + + scope_options_valid = SetPropertyCommand::HandleTestDirectoryScopes( + status, test_directory, test_directory_makefile); + return scope_options_valid; +} + std::string MakeSourceFilePathAbsoluteIfNeeded( cmExecutionStatus& status, const std::string& source_file_path, const bool needed) @@ -352,6 +407,9 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, bool source_file_directory_option_enabled = false; bool source_file_target_option_enabled = false; + std::string test_directory; + bool test_directory_option_enabled = false; + // Parse the rest of the arguments up to the values. enum Doing { @@ -360,7 +418,8 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, DoingProperty, DoingValues, DoingSourceDirectory, - DoingSourceTargetDirectory + DoingSourceTargetDirectory, + DoingTestDirectory, }; Doing doing = DoingNames; const char* sep = ""; @@ -385,12 +444,19 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, scope == cmProperty::SOURCE_FILE && arg == "TARGET_DIRECTORY") { doing = DoingSourceTargetDirectory; source_file_target_option_enabled = true; + } else if (doing != DoingProperty && doing != DoingValues && + scope == cmProperty::TEST && arg == "DIRECTORY") { + doing = DoingTestDirectory; + test_directory_option_enabled = true; } else if (doing == DoingNames) { names.insert(arg); } else if (doing == DoingSourceDirectory) { source_file_directories.push_back(arg); } else if (doing == DoingSourceTargetDirectory) { source_file_target_directories.push_back(arg); + } else if (doing == DoingTestDirectory) { + test_directory = arg; + doing = DoingNone; } else if (doing == DoingProperty) { propertyName = arg; doing = DoingValues; @@ -412,12 +478,17 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, } std::vector<cmMakefile*> source_file_directory_makefiles; - bool file_scopes_handled = + bool source_file_scopes_handled = SetPropertyCommand::HandleAndValidateSourceFileDirectoryScopes( status, source_file_directory_option_enabled, source_file_target_option_enabled, source_file_directories, source_file_target_directories, source_file_directory_makefiles); - if (!file_scopes_handled) { + cmMakefile* test_directory_makefile; + bool test_scopes_handled = + SetPropertyCommand::HandleAndValidateTestDirectoryScopes( + status, test_directory_option_enabled, test_directory, + test_directory_makefile); + if (!(source_file_scopes_handled && test_scopes_handled)) { return false; } bool source_file_paths_should_be_absolute = @@ -441,7 +512,8 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args, source_file_paths_should_be_absolute); case cmProperty::TEST: return HandleTestMode(status, names, propertyName, propertyValue, - appendAsString, appendMode, remove); + appendAsString, appendMode, remove, + test_directory_makefile); case cmProperty::CACHE: return HandleCacheMode(status, names, propertyName, propertyValue, appendAsString, appendMode, remove); @@ -642,14 +714,14 @@ bool HandleSource(cmSourceFile* sf, const std::string& propertyName, bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names, const std::string& propertyName, const std::string& propertyValue, bool appendAsString, - bool appendMode, bool remove) + bool appendMode, bool remove, cmMakefile* test_makefile) { // Look for tests with all names given. std::set<std::string>::iterator next; for (auto ni = names.begin(); ni != names.end(); ni = next) { next = ni; ++next; - if (cmTest* test = status.GetMakefile().GetTest(*ni)) { + if (cmTest* test = test_makefile->GetTest(*ni)) { if (HandleTest(test, propertyName, propertyValue, appendAsString, appendMode, remove)) { names.erase(ni); diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 05c4873..4d9480d 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -33,6 +33,18 @@ bool HandleAndValidateSourceFileDirectoryScopes( std::vector<std::string>& source_target_directories, std::vector<cmMakefile*>& source_file_directory_makefiles); +bool HandleTestDirectoryScopes(cmExecutionStatus& status, + std::string& test_directory, + cmMakefile*& directory_makefile); + +bool HandleTestDirectoryScopeValidation(cmExecutionStatus& status, + bool test_directory_option_enabled, + std::string& test_directory); + +bool HandleAndValidateTestDirectoryScopes( + cmExecutionStatus& status, bool test_directory_option_encountered, + std::string& test_directory, cmMakefile*& test_directory_makefile); + std::string MakeSourceFilePathAbsoluteIfNeeded( cmExecutionStatus& status, const std::string& source_file_path, bool needed); void MakeSourceFilePathsAbsoluteIfNeeded( diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index a17c964..2ac445c 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -5,9 +5,15 @@ #include <algorithm> #include <iterator> +#include <cmext/string_view> + +#include "cmArgumentParser.h" #include "cmExecutionStatus.h" +#include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmRange.h" #include "cmStringAlgorithms.h" +#include "cmSystemTools.h" #include "cmTest.h" bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args, @@ -31,9 +37,29 @@ bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args, return false; } + std::vector<std::string> tests; + std::string directory; + cmArgumentParser<void> parser; + parser.Bind("DIRECTORY"_s, directory); + auto result = parser.Parse(cmStringRange{ args.begin(), propsIter }, &tests); + + cmMakefile* mf = &status.GetMakefile(); + if (result.MaybeReportError(*mf)) { + return false; + } + if (!directory.empty()) { + std::string absDirectory = cmSystemTools::CollapseFullPath( + directory, mf->GetCurrentSourceDirectory()); + mf = mf->GetGlobalGenerator()->FindMakefile(absDirectory); + if (!mf) { + status.SetError(cmStrCat("given non-existent DIRECTORY ", directory)); + return false; + } + } + // loop over all the tests - for (const std::string& tname : cmStringRange{ args.begin(), propsIter }) { - if (cmTest* test = status.GetMakefile().GetTest(tname)) { + for (const std::string& tname : tests) { + if (cmTest* test = mf->GetTest(tname)) { // loop through all the props and set them for (auto k = propsIter + 1; k != args.end(); k += 2) { if (!k->empty()) { 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) |