]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tests: print a nice summary after the invocation of the setup_tests macro
authorMatthias Maier <tamiko@43-1.org>
Sat, 1 Jul 2023 04:47:48 +0000 (23:47 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 1 Jul 2023 05:07:34 +0000 (00:07 -0500)
tests/CMakeLists.txt
tests/scripts/print_summary_files.cmake [new file with mode: 0644]
tests/scripts/remove_summary_files.cmake [new file with mode: 0644]

index 8c3043924d2c329deac5d2a5069e1a20f0108c5a..55069f3d22203deeffc3d5872bbe6972283a8c9d 100644 (file)
@@ -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 (file)
index 0000000..83f8bb1
--- /dev/null
@@ -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 (file)
index 0000000..a8024dc
--- /dev/null
@@ -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()

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.