project(testsuite CXX)
#
-# Make sure that we have been called with a proper deal.II source directory
-# layout:
+# Setting up example tests is a bit tricky because we need to patch the
+# current source file of the examples to make them suitable for the
+# testsuite (sanitize output, reduce run time).
#
-set(DEAL_II_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../..")
+# We thus create a set of "source" and "binary" sub directories in our
+# CMAKE_CURRENT_BINARY_DIR that we can manipulate at will. We then populate
+# the source directory with all (dynamically) patched step-*.cc files,
+# create symlinks to all output files, and put the CMakelists.txt.in file
+# in place.
+#
+# As a last step we call into the subdirectory and process all tests:
+#
+
+set(DEAL_II_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
if (EXISTS "${DEAL_II_SOURCE_DIR}/examples")
#
# Create CMake file structure in the current binary dir:
#
+ set(_base_directory "${CMAKE_CURRENT_SOURCE_DIR}")
set(_source_directory "${CMAKE_CURRENT_BINARY_DIR}/source")
set(_binary_directory "${CMAKE_CURRENT_BINARY_DIR}/binary")
message(STATUS "Temporary source directory: ${_source_directory}")
message(STATUS "Temporary binary directory: ${_binary_directory}")
file(MAKE_DIRECTORY "${_source_directory}")
- file(WRITE "${_source_directory}/CMakeLists.txt" "deal_ii_pickup_tests(examples)")
+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/example_test.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in" "${_source_directory}/CMakeLists.txt"
+ COPYONLY
+ )
enable_testing()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CTestFile.cmake" "subdirs(binary)")
- #
- # Create tests from diffs:
- #
- execute_process(
- COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/update.sh" "${DEAL_II_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
- WORKING_DIRECTORY "${_source_directory}"
- )
-
+ # and now call into the second half of our setup in the writable "source"
+ # directory:
add_subdirectory(${_source_directory} ${_binary_directory})
-
- #
- # Create a top-level diff target:
- #
- add_custom_target(update_diffs
- COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/update_diffs.sh" "${DEAL_II_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
- WORKING_DIRECTORY "${_source_directory}"
- )
endif()
--- /dev/null
+#
+# Parse all diff files...
+#
+
+file(GLOB _diff_files "${_base_directory}/*.diff")
+foreach(_diff_file ${_diff_files})
+ get_filename_component(_step "${_diff_file}" NAME_WLE)
+ set(_source_file "${DEAL_II_SOURCE_DIR}/examples/${_step}/${_step}.cc")
+ set(_output_file "${_source_directory}/${_step}.cc")
+
+ # ... and create a rule that updates all diff files if necessary during
+ # testsuite invocation:
+ add_custom_command(OUTPUT ${_output_file}
+ COMMAND patch ${_source_file} ${_diff_file} -o ${_output_file}
+ DEPENDS ${_source_file} ${_diff_file}
+ COMMENT "Patching ${_output_file}"
+ )
+
+ execute_process(
+ COMMAND patch ${_source_file} ${_diff_file} -o ${_output_file}
+ )
+
+ # Create symbolic links to the output files:
+ file(GLOB _output_files "${_base_directory}/${_step}*.output*")
+ foreach(_file ${_output_files})
+ get_filename_component(_destination "${_file}" NAME)
+ set(_destination "${_source_directory}/${_destination}")
+ file(CREATE_LINK ${_file} ${_destination} SYMBOLIC)
+ endforeach()
+endforeach()
+
+#
+# Create a top-level diff target:
+#
+
+add_custom_target(update_diffs
+ COMMAND "${_base_directory}/update_diffs.sh" "${DEAL_II_SOURCE_DIR}" "${_base_directory}"
+ WORKING_DIRECTORY "${_source_directory}"
+ )
+
+deal_ii_pickup_tests(examples)
+++ /dev/null
-#!/bin/bash
-set -eu
-
-DEAL_II_SOURCE_DIR="${1}"
-shift
-CMAKE_CURRENT_SOURCE_DIR="${1}"
-shift
-
-#
-# use .diff files to create .cc files
-#
-
-# Find all *.diff files in the current directory
-diff_files="$(find ${CMAKE_CURRENT_SOURCE_DIR} -maxdepth 1 -type f -name "*.diff")"
-
-for file in ${diff_files}; do
- # Extract the filename without the extension
- filename="$(basename "${file}" ".diff")"
- source_file="${DEAL_II_SOURCE_DIR}/examples/${filename}/${filename}.cc"
- output_files="${CMAKE_CURRENT_SOURCE_DIR}/${filename}*.output*"
-
- # Check if the corresponding .cc file exists
- if [[ -f "${source_file}" ]]; then
- # Apply the diff and save it to a new file
- patch "${source_file}" -o "${filename}.cc" < "${file}"
- echo "copying file(s) ${output_files}"
- cp ${output_files} .
- else
- echo "No matching .cc file found for ${file}"
- exit 1
- fi
-done