From a6b285aeee2e5f8c44d298bcdb610de1218c365e Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 4 Jul 2023 09:25:49 -0500 Subject: [PATCH] Quick tests: make quick test output more responsive --- tests/CMakeLists.txt | 1 + tests/run_quick_tests.cmake | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f3fe17a96c..ce5d7a0e44 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -174,6 +174,7 @@ add_custom_target(test COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${_my_build} -P ${CMAKE_CURRENT_SOURCE_DIR}/run_quick_tests.cmake WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Running quicktests..." + USES_TERMINAL ) add_dependencies(test setup_tests_quick_tests) diff --git a/tests/run_quick_tests.cmake b/tests/run_quick_tests.cmake index 4f79df5969..978d87c9ec 100644 --- a/tests/run_quick_tests.cmake +++ b/tests/run_quick_tests.cmake @@ -36,6 +36,20 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "") endif() message(STATUS "Running quick_tests in ${CMAKE_BUILD_TYPE} mode with -j${_n_processors}:") +# +# Redirect quick tests to an output.log for CMake versions 3.18 onwards +# (when we can actually instruct CMake to also print to the standard +# terminal). +# + +set(_redirect_output "") +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) + set(_redirect_output + OUTPUT_VARIABLE _output ECHO_OUTPUT_VARIABLE + ERROR_VARIABLE _output ECHO_ERROR_VARIABLE + ) +endif() + # # Always restrict quick tests with specified build type, but run the step # and affinity quick tests in all available configuration: @@ -45,10 +59,11 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type) execute_process(COMMAND ${CMAKE_CTEST_COMMAND} -j${_n_processors} -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process -R "quick_tests/(step.debug|step.release|affinity|.*.${_build_type})" - OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _return_value + --output-on-failure + ${_redirect_output} + RESULT_VARIABLE _return_value ) file(WRITE quick_tests.log ${_output}) -message(${_output}) if(NOT "${_return_value}" STREQUAL "0") message(" -- 2.39.5