CTest: build-and-test outputs the configure output only after it finishes
Looks like ctest --build-and-test
buffers the configure output, and only prints it once the configure step has finished.
If the configure step takes a long time, there is no indication whether there is any progress or if the test is stuck. This can also cause issues in a CI system, where a timeout watcher might kill the job if there is no output for some time.
Can be reproduced with:
cmake_minimum_required(VERSION 3.16)
project(proj)
set(src_dir "${CMAKE_BINARY_DIR}/src")
set(build_dir "${CMAKE_BINARY_DIR}/build")
set(source_path "${src_dir}/CMakeLists.txt")
set(source_project [=[
cmake_minimum_required(VERSION 3.16)
project(foo)
message("before 2s sleep")
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 2)
message("after 2s sleep")
]=]
)
file(WRITE "${source_path}" "${source_project}")
set(ctest_command_args
--build-and-test
"${src_dir}"
"${build_dir}"
--build-generator ${CMAKE_GENERATOR}
)
include(CTest)
add_test(NAME "build_project" COMMAND ${CMAKE_CTEST_COMMAND} ${ctest_command_args})
ctest --build-and-test
should either not buffer the configure output, or learn a new option --echo-configure-output
to opt into the new behavior.
Edited by alcroito