mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
ctest: Disable pre- and post-processing during --show-only
Do not run the custom pre-/post- test tasks when instructed to only show the tests that would be executed. Otherwise it's impossible to reliably parse the output of this as is will be contaminated by all output produced by the pre-/post-scripts! Fixes: #23254
This commit is contained in:
committed by
Brad King
parent
aef87a3378
commit
3e89f5ae83
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
^Test project [^
|
||||
]+/Tests/RunCMake/CTestCommandLine/CustomPrePost
|
||||
Test #1: Echo
|
||||
|
||||
Total Tests: 1$
|
||||
@@ -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$
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user