Merge topic 'ctest-show-only-no-custom-processing'

3e89f5ae83 ctest: Disable pre- and post-processing during `--show-only`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11763
This commit is contained in:
Brad King
2026-03-04 14:36:11 +00:00
committed by Kitware Robot
4 changed files with 33 additions and 2 deletions

View File

@@ -359,7 +359,7 @@ int cmCTestTestHandler::ProcessHandler()
<< cmSystemTools::GetLogicalWorkingDirectory()
<< std::endl,
this->Quiet);
if (!this->PreProcessHandler()) {
if (!this->CTest->GetShowOnly() && !this->PreProcessHandler()) {
return -1;
}
@@ -428,7 +428,7 @@ int cmCTestTestHandler::ProcessHandler()
return 1;
}
if (!this->PostProcessHandler()) {
if (!this->CTest->GetShowOnly() && !this->PostProcessHandler()) {
this->LogFile = nullptr;
return -1;
}

View File

@@ -0,0 +1,5 @@
^Test project [^
]+/Tests/RunCMake/CTestCommandLine/CustomPrePost
Test #1: Echo
Total Tests: 1$

View File

@@ -0,0 +1,10 @@
^Test project [^
]+/Tests/RunCMake/CTestCommandLine/CustomPrePost
Custom Pre-Test
Start 1: Echo
1/1 Test #1: Echo \.+ Passed +[0-9\.]+ sec
100% tests passed, 0 tests failed out of 1
Total Test time \(real\) = +[0-9\.]+ sec
Custom Post-Test$

View File

@@ -492,6 +492,22 @@ function(show_only_json_check_python v)
return(PROPAGATE RunCMake_TEST_FAILED)
endfunction()
block()
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomPrePost)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestCustom.cmake" "
set(CTEST_CUSTOM_PRE_TEST \"\\\"${CMAKE_COMMAND}\\\" -E echo \\\"Custom Pre-Test\\\"\")
set(CTEST_CUSTOM_POST_TEST \"\\\"${CMAKE_COMMAND}\\\" -E echo \\\"Custom Post-Test\\\"\")
")
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
add_test(Echo \"${CMAKE_COMMAND}\" -E echo)
")
run_cmake_command(CustomPrePost ${CMAKE_CTEST_COMMAND})
run_cmake_command(CustomPrePost-show-only ${CMAKE_CTEST_COMMAND} --show-only=human)
endblock()
function(run_ShowOnly)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowOnly)
set(RunCMake_TEST_NO_CLEAN 1)