Merge topic 'instrumentation-disabled-test-fix' into release-4.3

180746bc7c instrumentation: Don't instrument disabled tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12033
This commit is contained in:
Brad King
2026-05-13 17:31:16 +00:00
committed by Kitware Robot
5 changed files with 17 additions and 2 deletions

View File

@@ -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(),

View File

@@ -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

View File

@@ -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)

View File

@@ -0,0 +1 @@
No tests were found!!!

View File

@@ -41,6 +41,9 @@ add_custom_target(customTarget ALL
DEPENDS output1 shell_redirect.out
)
add_test(NAME test COMMAND $<TARGET_FILE:main>)
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")