Skip to content

Commit

Permalink
Add an argument to exclude SIO files from some tests (AIDASoft#387)
Browse files Browse the repository at this point in the history
* Actually check extension model dumping

* Rework script and CMakeLists to pass in more information in
  environment

* Also check when clang format is used
---------

Co-authored-by: jmcarcell <jmcarcell@users.noreply.github.com>
Co-authored-by: Thomas Madlener <thomas.madlener@desy.de>
  • Loading branch information
3 people committed May 3, 2023
1 parent 2c85f98 commit 90ec0cf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
36 changes: 29 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,19 @@ endif()

# Add tests for storing and retrieving the EDM definitions into the produced
# files
add_test(datamodel_def_store_roundtrip_root ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.root datamodel)
add_test(datamodel_def_store_roundtrip_root_extension ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.root datamodel extension_datamodel)

add_test(datamodel_def_store_roundtrip_root ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh
${CMAKE_CURRENT_BINARY_DIR}/example_frame.root
datamodel
${CMAKE_CURRENT_LIST_DIR}
)
# The extension model needs to know about the upstream model for generation
add_test(datamodel_def_store_roundtrip_root_extension
${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh
${CMAKE_CURRENT_BINARY_DIR}/example_frame.root
extension_model
${CMAKE_CURRENT_LIST_DIR}/extension_model
--upstream-edm=datamodel:${CMAKE_CURRENT_LIST_DIR}/datalayout.yaml
)

# Need the input files that are produced by other tests
set_tests_properties(
Expand All @@ -263,9 +273,21 @@ set_tests_properties(
)

set(sio_roundtrip_tests "")
if (TARGET read_sio)
add_test(datamodel_def_store_roundtrip_sio ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio datamodel)
add_test(datamodel_def_store_roundtrip_sio_extension ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio datamodel extension_datamodel)
if (ENABLE_SIO)
add_test(datamodel_def_store_roundtrip_sio
${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh
${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio
datamodel
${CMAKE_CURRENT_LIST_DIR}
)
# The extension model needs to know about the upstream model for generation
add_test(datamodel_def_store_roundtrip_sio_extension
${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh
${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio
extension_model
${CMAKE_CURRENT_LIST_DIR}/extension_model
--upstream-edm=datamodel:${CMAKE_CURRENT_LIST_DIR}/datalayout.yaml
)

set(sio_roundtrip_tests
datamodel_def_store_roundtrip_sio
Expand All @@ -289,5 +311,5 @@ set_tests_properties(
PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
ENVIRONMENT
"PODIO_BASE=${CMAKE_SOURCE_DIR};IO_HANDLERS=${IO_HANDLERS};LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_SOURCE_DIR}/python:$ENV{PYTHONPATH};ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/tests/datamodel:${CMAKE_SOURCE_DIR}/include:$ENV{ROOT_INCLUDE_PATH}"
"PODIO_BASE=${CMAKE_SOURCE_DIR};IO_HANDLERS=${IO_HANDLERS};ENABLE_SIO=${ENABLE_SIO};PODIO_USE_CLANG_FORMAT=${PODIO_USE_CLANG_FORMAT};LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_SOURCE_DIR}/python:$ENV{PYTHONPATH};ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/tests/datamodel:${CMAKE_SOURCE_DIR}/include:$ENV{ROOT_INCLUDE_PATH}"
)
26 changes: 17 additions & 9 deletions tests/scripts/dumpModelRoundTrip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
# the original definition. Essentially does not check that the YAML file is the
# same, but rather that the generated code is the same

set -eu
set -eux

INPUT_FILE=${1} # the datafile
EDM_NAME=${2} # the name of the EDM
COMP_BASE_FOLDER="" # where the source to compare against is
if [ -$# -gt 2 ]; then
COMP_BASE_FOLDER=${3}
COMP_BASE_FOLDER=${3} # where the source to compare against is
shift 3
EXTRA_GEN_ARGS=${@}

if [ ${PODIO_USE_CLANG_FORMAT} = "ON" ] || [ ${PODIO_USE_CLANG_FORMAT} = "AUTO" ]; then
EXTRA_GEN_ARGS="${EXTRA_GEN_ARGS} --clangformat"
fi

# Create a few temporary but unique files and directories to store output
Expand All @@ -20,9 +23,9 @@ mkdir -p ${OUTPUT_FOLDER}
# Dump the model to a yaml file
${PODIO_BASE}/tools/podio-dump --dump-edm ${EDM_NAME} ${INPUT_FILE} > ${DUMPED_MODEL}

# Regenerate the code via the class generator and the freshly dumped modl
# Regenerate the code via the class generator and the freshly dumped model
${PODIO_BASE}/python/podio_class_generator.py \
--clangformat \
${EXTRA_GEN_ARGS} \
${DUMPED_MODEL} \
${OUTPUT_FOLDER} \
${EDM_NAME} \
Expand All @@ -31,6 +34,11 @@ ${PODIO_BASE}/python/podio_class_generator.py \
# Compare to the originally generated code, that has been used to write the data
# file. Need to diff subfolders explitly here because $PODIO_BASE/tests contains
# more stuff
diff -ru ${OUTPUT_FOLDER}/${EDM_NAME} ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/${EDM_NAME}
diff -ru ${OUTPUT_FOLDER}/src ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/src
diff -u ${OUTPUT_FOLDER}/podio_generated_files.cmake ${PODIO_BASE}/tests/podio_generated_files.cmake
DIFF_EXTRA_ARGS=""
if [ ${ENABLE_SIO} = "OFF" ]; then
DIFF_EXTRA_ARGS=--exclude='*SIO*'
fi

diff -ru ${OUTPUT_FOLDER}/${EDM_NAME} ${COMP_BASE_FOLDER}/${EDM_NAME} ${DIFF_EXTRA_ARGS}
diff -ru ${OUTPUT_FOLDER}/src ${COMP_BASE_FOLDER}/src ${DIFF_EXTRA_ARGS}
diff -u ${OUTPUT_FOLDER}/podio_generated_files.cmake ${COMP_BASE_FOLDER}/podio_generated_files.cmake

0 comments on commit 90ec0cf

Please sign in to comment.