From: Matthias Maier Date: Sat, 1 Jul 2023 04:47:48 +0000 (-0500) Subject: Tests: print a nice summary after the invocation of the setup_tests macro X-Git-Tag: relicensing~824^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86e615b8f63bc90571140117cfc727b17a8fa31e;p=dealii.git Tests: print a nice summary after the invocation of the setup_tests macro --- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8c3043924d..55069f3d22 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -107,11 +107,26 @@ endforeach() # Custom targets for the testsuite: # -# Setup tests: -add_custom_target(setup_tests) +# +# Clear the test summary files that records how many tests have been configured. +# +set(_summary_files_prefix "${CMAKE_CURRENT_BINARY_DIR}/test_summary") + +# Set up all tests and print a summary: +add_custom_target(setup_tests + COMMAND ${CMAKE_COMMAND} + -D_summary_files_prefix="${_summary_files_prefix}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/scripts/print_summary_files.cmake + COMMENT "Setting up tests and printing test summary" + ) -# Remove all tests: -add_custom_target(prune_tests) +# Remove all tests and also remove all test summary files: +add_custom_target(prune_tests + COMMAND ${CMAKE_COMMAND} + -D_summary_files_prefix="${_summary_files_prefix}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/scripts/remove_summary_files.cmake + COMMENT "Cleaning tests and removing test summary files" + ) foreach(_category ${_categories}) set(_category_dir ${CMAKE_CURRENT_SOURCE_DIR}/${_category}) @@ -124,7 +139,8 @@ foreach(_category ${_categories}) # Do not pass the generator with -G so that we use make instead of ninja # for the test projects. This is because calling ninja several times in # parallel for the same project will break the configuration. - set(_command ${CMAKE_COMMAND} ${_options} ${_category_dir} > /dev/null) + + set(_command ${CMAKE_COMMAND} ${_options} ${_category_dir} > "${_summary_files_prefix}_${_category}") endif() add_custom_target(setup_tests_${_category} diff --git a/tests/scripts/print_summary_files.cmake b/tests/scripts/print_summary_files.cmake new file mode 100644 index 0000000000..83f8bb1171 --- /dev/null +++ b/tests/scripts/print_summary_files.cmake @@ -0,0 +1,15 @@ +# +# Glob all test summary files and print them +# + +if("${_summary_files_prefix}" STREQUAL "") + message(FATAL_ERROR "The variable _summary_files_prefix is not set.") +endif() + +file(GLOB _files "${_summary_files_prefix}_*") +foreach(_file ${_files}) + file(STRINGS "${_file}" _summary_string REGEX "Test category ") + if(NOT "${_summary_string}" STREQUAL "") + message("${_summary_string}") + endif() +endforeach() diff --git a/tests/scripts/remove_summary_files.cmake b/tests/scripts/remove_summary_files.cmake new file mode 100644 index 0000000000..a8024dc696 --- /dev/null +++ b/tests/scripts/remove_summary_files.cmake @@ -0,0 +1,12 @@ +# +# Glob all test summary files and remove them +# + +if("${_summary_files_prefix}" STREQUAL "") + message(FATAL_ERROR "The variable _summary_files_prefix is not set.") +endif() + +file(GLOB _files "${_summary_files_prefix}_*") +if(NOT "${_files}" STREQUAL "") + file(REMOVE ${_files}) +endif()