From 180746bc7ca4bf20ae4a9b8f6ed7f1dd20dc6a3e Mon Sep 17 00:00:00 2001 From: Martin Duffy Date: Fri, 8 May 2026 14:39:51 -0400 Subject: [PATCH] instrumentation: Don't instrument disabled tests Fixes: #27791 --- Source/CTest/cmCTestRunTest.cxx | 2 +- Tests/RunCMake/Instrumentation/RunCMakeTest.cmake | 8 ++++++++ Tests/RunCMake/Instrumentation/check-data-dir.cmake | 5 ++++- .../Instrumentation/disabled-test-test-stderr.txt | 1 + Tests/RunCMake/Instrumentation/project/CMakeLists.txt | 3 +++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/Instrumentation/disabled-test-test-stderr.txt diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 97b1d16989..207dd33a63 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -1025,7 +1025,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) void cmCTestRunTest::FinalizeTest(bool started) { - if (this->CTest->GetInstrumentation().HasQuery()) { + if (started && this->CTest->GetInstrumentation().HasQuery()) { std::string data_file = this->CTest->GetInstrumentation().InstrumentTest( this->TestProperties->Name, this->ActualCommand, this->Arguments, this->TestProcess->GetExitValue(), this->TestProcess->GetStartTime(), diff --git a/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake b/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake index 73061ebfa8..c364350146 100644 --- a/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake +++ b/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake @@ -20,6 +20,7 @@ function(instrument test) "MANUAL_HOOK" "PRESERVE_DATA" "NO_CONFIGURE" + "DISABLE_TEST" "FAIL" "BAD_QUERY" ) @@ -94,6 +95,9 @@ function(instrument test) if (ARGS_FAIL) list(APPEND ARGS_CONFIGURE_ARG "-DFAIL=ON") endif() + if (ARGS_DISABLE_TEST) + list(APPEND ARGS_CONFIGURE_ARG "-DDISABLE_TEST=ON") + endif() set(RunCMake_TEST_SOURCE_DIR ${RunCMake_SOURCE_DIR}/project) if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(maybe_CMAKE_BUILD_TYPE -DCMAKE_BUILD_TYPE=Debug) @@ -208,6 +212,10 @@ instrument(no-query BUILD INSTALL TEST CHECK_SCRIPT check-data-dir.cmake ) +instrument(disabled-test + BUILD TEST DISABLE_TEST + CHECK_SCRIPT check-data-dir.cmake +) instrument(dynamic-query BUILD INSTALL TEST DYNAMIC_QUERY CHECK_SCRIPT check-data-dir.cmake diff --git a/Tests/RunCMake/Instrumentation/check-data-dir.cmake b/Tests/RunCMake/Instrumentation/check-data-dir.cmake index 72b0f1f0b9..a72a64ea31 100644 --- a/Tests/RunCMake/Instrumentation/check-data-dir.cmake +++ b/Tests/RunCMake/Instrumentation/check-data-dir.cmake @@ -160,7 +160,10 @@ if (ARGS_BUILD OR ARGS_BUILD_MAKE_PROGRAM) endif() endif() if (ARGS_TEST) - list(APPEND EXPECTED_SNIPPETS ctest test) + list(APPEND EXPECTED_SNIPPETS ctest) + if (NOT ARGS_DISABLE_TEST) + list(APPEND EXPECTED_SNIPPETS test) + endif() endif() if (ARGS_INSTALL) list(APPEND EXPECTED_SNIPPETS cmakeInstall) diff --git a/Tests/RunCMake/Instrumentation/disabled-test-test-stderr.txt b/Tests/RunCMake/Instrumentation/disabled-test-test-stderr.txt new file mode 100644 index 0000000000..eafba1c692 --- /dev/null +++ b/Tests/RunCMake/Instrumentation/disabled-test-test-stderr.txt @@ -0,0 +1 @@ +No tests were found!!! diff --git a/Tests/RunCMake/Instrumentation/project/CMakeLists.txt b/Tests/RunCMake/Instrumentation/project/CMakeLists.txt index 6e7f2457ce..f713c8a398 100644 --- a/Tests/RunCMake/Instrumentation/project/CMakeLists.txt +++ b/Tests/RunCMake/Instrumentation/project/CMakeLists.txt @@ -41,6 +41,9 @@ add_custom_target(customTarget ALL DEPENDS output1 shell_redirect.out ) add_test(NAME test COMMAND $) +if(DISABLE_TEST) + set_tests_properties(test PROPERTIES DISABLED TRUE) +endif() install(TARGETS main) set_target_properties(main PROPERTIES LABELS "label1;label2") set_target_properties(lib PROPERTIES LABELS "label3")