include(../scripts/setup_testsubproject.cmake)
project(testsuite CXX)
-# create tests from diffs:
-execute_process(
- COMMAND "./update.sh"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
+#
+# Make sure that we have been called with a proper deal.II source directory
+# layout:
+#
+set(DEAL_II_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../..")
+if (EXISTS "${DEAL_II_SOURCE_DIR}/examples")
+ #
+ # Create CMake file structure in the current binary 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}/../tests.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
-deal_ii_pickup_tests()
+ 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}"
+ )
+
+ 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
-#!/bin/bash
-
-# create .diff files from current .cc files
-
-# Find all *.diff files in the current directory
-diff_files=$(find . -maxdepth 1 -type f -name "*.diff")
-
-for file in $diff_files; do
- # Extract the filename without the extension
- filename=$(basename "$file" .diff)
- src="../../examples/$filename/$filename.cc"
-
- # Check if the corresponding .cc file exists
- if [[ -f "$src" ]]; then
- echo "creating $file from $src and $filename.cc"
- diff "$src" "$filename.cc" > "$file"
- else
- echo "No matching .cc file found for $file"
- exit 1
- fi
-done
#!/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 . -maxdepth 1 -type f -name "*.diff")
+diff_files="$(find ${CMAKE_CURRENT_SOURCE_DIR} -maxdepth 1 -type f -name "*.diff")"
-for file in $diff_files; do
+for file in ${diff_files}; do
# Extract the filename without the extension
- filename=$(basename "$file" .diff)
- src="../../examples/$filename/$filename.cc"
+ 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 "$src" ]]; then
+ if [[ -f "${source_file}" ]]; then
# Apply the diff and save it to a new file
- patch "$src" -o "$filename.cc" < "$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
--- /dev/null
+#!/bin/bash
+set -u
+
+DEAL_II_SOURCE_DIR="${1}"
+shift
+CMAKE_CURRENT_SOURCE_DIR="${1}"
+shift
+
+#
+# update .diff files from current .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"
+ modified_file="${filename}.cc"
+
+ # Check if the corresponding .cc file exists
+ if [[ -f "${source_file}" && -f "${modified_file}" ]]; then
+ echo diff "${source_file}" "${modified_file}" "${file}"
+ diff -Nur "${source_file}" "${modified_file}" > "${file}"
+ echo success
+ else
+ echo "No matching .cc files found for ${file}"
+ exit 1
+ fi
+done