Skip to content

Commit

Permalink
tests: also test root output writing output files
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Aug 10, 2024
1 parent 28e2f03 commit bdb1d42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/output/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(_visit_hdf5 "false")

# executable for converting remage output HDF5 with ntuples to LH5 tables
set(_visit_hdf5 "false")
if(Geant4_hdf5_FOUND)
add_executable(test-visit-hdf5 EXCLUDE_FROM_ALL test-visit-hdf5.cc)
target_include_directories(test-visit-hdf5 PRIVATE ${HDF5_INCLUDE_DIRS})
Expand All @@ -15,7 +14,7 @@ endif()
file(
GLOB _aux
RELATIVE ${PROJECT_SOURCE_DIR}
macros/*.mac macros/*.hdf5ls gdml/*.gdml gdml/*.xml run-test-hdf5.sh)
macros/*.mac macros/*.hdf5ls gdml/*.gdml gdml/*.xml run-test-*.sh)

# copy them to the build area
foreach(_file ${_aux})
Expand All @@ -25,14 +24,15 @@ endforeach()
set(_macros ntuple-per-det.mac ntuple-flat.mac)

foreach(_mac ${_macros})
add_test(NAME output/${_mac} COMMAND ./run-test-hdf5.sh $<TARGET_FILE:remage-cli> ${_visit_hdf5}
${_mac})
add_test(NAME output/hdf5-${_mac} COMMAND ./run-test-hdf5.sh $<TARGET_FILE:remage-cli>
${_visit_hdf5} ${_mac})
add_test(NAME output/root-${_mac} COMMAND ./run-test-root.sh $<TARGET_FILE:remage-cli> ${_mac})
endforeach()

list(TRANSFORM _macros PREPEND "output/")
set_tests_properties(${_macros} PROPERTIES LABELS extra DEPENDS output/build-test-visit-hdf5)
list(TRANSFORM _macros PREPEND "output/hdf5-" OUTPUT_VARIABLE _macros_hdf5)
set_tests_properties(${_macros_hdf5} PROPERTIES LABELS extra DEPENDS output/build-test-visit-hdf5)

# Geant4 <= 11.0.3 is deleting non-empty HDF5 files after a successful run, so disable the tests.
if(Geant4_VERSION VERSION_LESS "11.0.4" OR NOT Geant4_hdf5_FOUND)
set_tests_properties(${_macros} PROPERTIES DISABLED True)
set_tests_properties(${_macros_hdf5} PROPERTIES DISABLED True)
endif()
13 changes: 13 additions & 0 deletions tests/output/run-test-root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

rmg="$1"
macro="macros/$2"
output="${2/.mac/.root}"

# run remage, produce root output.
"$rmg" -g gdml/geometry.gdml -o "$output" -- "$macro"

# check that output file is there.
test -f "$output"

0 comments on commit bdb1d42

Please sign in to comment.