Skip to content

Commit

Permalink
Actually check extension model dumping
Browse files Browse the repository at this point in the history
- Rework script and CMakeLists to pass in more information in
  environment
- Format CMakeLists for slightly better readability
  • Loading branch information
tmadlener committed Apr 3, 2023
1 parent 7824f3a commit 5e6846d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
41 changes: 29 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,19 @@ endif()

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

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 @@ -269,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 false ${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio datamodel)
add_test(datamodel_def_store_roundtrip_sio_extension ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh false ${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 @@ -295,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}"
)
29 changes: 14 additions & 15 deletions tests/scripts/dumpModelRoundTrip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +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 -e
set -eux

EXCLUDE_SIO=${1} # SIO excluded or not
INPUT_FILE=${2} # the datafile
EDM_NAME=${3} # the name of the EDM
COMP_BASE_FOLDER="" # where the source to compare against is
if [ -$# -gt 3 ]; then
COMP_BASE_FOLDER=${4}
fi
INPUT_FILE=${1} # the datafile
EDM_NAME=${2} # the name of the EDM
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 @@ -24,6 +22,7 @@ ${PODIO_BASE}/tools/podio-dump --dump-edm ${EDM_NAME} ${INPUT_FILE} > ${DUMPED_M
# 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 @@ -32,11 +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
if [ ${EXCLUDE_SIO} = "true" ]; then
diff -ru ${OUTPUT_FOLDER}/${EDM_NAME} ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/${EDM_NAME} --exclude='*SIO*'
diff -ru ${OUTPUT_FOLDER}/src ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/src --exclude='*SIO*'
else
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_EXTRA_ARGS=""
if [ ${ENABLE_SIO} = "OFF" ]; then
DIFF_EXTRA_ARGS=--exclude='*SIO*'
fi
diff -u ${OUTPUT_FOLDER}/podio_generated_files.cmake ${PODIO_BASE}/tests/podio_generated_files.cmake

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 5e6846d

Please sign in to comment.