summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-07-28 13:43:04 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2021-07-28 13:58:28 (GMT)
commit26170ea3069238bfb287d6304cd2f65e1c3a7387 (patch)
tree09194a58abaee92019cd3c878fc36621341ec808
parentf7cf69e34a1607e8ea2b6d10fef6a6058377c24e (diff)
downloadCMake-26170ea3069238bfb287d6304cd2f65e1c3a7387.zip
CMake-26170ea3069238bfb287d6304cd2f65e1c3a7387.tar.gz
CMake-26170ea3069238bfb287d6304cd2f65e1c3a7387.tar.bz2
CTest: Reset multi-options to persistent multi-options
44ad3f0b added multi-options to CTest, but didn't reset them, causing ctest_test() to fail if it was run multiple times with different label arguments. Reset the multi-options. Fixes: #22485
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx6
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/ctest_test/test.cmake.in7
3 files changed, 21 insertions, 5 deletions
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index cc756d7..48cc0e4 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -68,10 +68,8 @@ void cmCTestGenericHandler::Initialize()
{
this->AppendXML = false;
this->TestLoad = 0;
- this->Options.clear();
- for (auto const& po : this->PersistentOptions) {
- this->Options[po.first] = po.second;
- }
+ this->Options = this->PersistentOptions;
+ this->MultiOptions = this->PersistentMultiOptions;
}
const char* cmCTestGenericHandler::GetOption(const std::string& op)
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index f07a12b..5f9b32d 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -181,3 +181,16 @@ add_test(
run_ctest(TestCompletionStatus)
endfunction()
run_completion_status()
+
+# Verify that running ctest_test() multiple times with different label arguments
+# doesn't break.
+function(run_changing_labels)
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_test(NAME a COMMAND ${CMAKE_COMMAND} -E true)
+set_property(TEST a PROPERTY LABELS a)
+add_test(NAME b COMMAND ${CMAKE_COMMAND} -E true)
+set_property(TEST b PROPERTY LABELS b)
+ ]])
+ run_ctest(TestChangingLabels)
+endfunction()
+run_changing_labels()
diff --git a/Tests/RunCMake/ctest_test/test.cmake.in b/Tests/RunCMake/ctest_test/test.cmake.in
index 50b936d..36b1dbd 100644
--- a/Tests/RunCMake/ctest_test/test.cmake.in
+++ b/Tests/RunCMake/ctest_test/test.cmake.in
@@ -15,4 +15,9 @@ set(ctest_test_args "@CASE_CTEST_TEST_ARGS@")
ctest_start(Experimental)
ctest_configure()
ctest_build()
-ctest_test(${ctest_test_args})
+if("@CASE_NAME@" STREQUAL "TestChangingLabels")
+ ctest_test(${ctest_test_args} INCLUDE_LABEL "^a$")
+ ctest_test(${ctest_test_args} INCLUDE_LABEL "^b$")
+else()
+ ctest_test(${ctest_test_args})
+endif()