Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an argument to exclude SIO files from some tests #387

Merged
merged 8 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,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 @@ -264,9 +274,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 @@ -290,5 +312,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};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}"
)
23 changes: 14 additions & 9 deletions tests/scripts/dumpModelRoundTrip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
# 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}
fi
COMP_BASE_FOLDER=${3} # where the source to compare against is
shift 3
EXTRA_GEN_ARGS=${@}

# Create a few temporary but unique files and directories to store output
DUMPED_MODEL=${INPUT_FILE}.dumped_${EDM_NAME}.yaml
Expand All @@ -20,9 +19,10 @@ 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 +31,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