Skip to content

Commit

Permalink
Switch podio-dump tests to use ExternalData
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 12, 2023
1 parent a772a4c commit 1a04d1a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,20 @@ add_subdirectory(src)
SET(podio_PYTHON_DIR ${PROJECT_SOURCE_DIR}/python CACHE PATH "Path to the podio python directory")

if(BUILD_TESTING)
include(ExternalData)
list(APPEND ExternalData_URL_TEMPLATES
"https://key4hep.web.cern.ch:443/testFiles/podio/%(hash)"
)
include(cmake/podioTest.cmake)
add_subdirectory(tests)
endif()
add_subdirectory(tools)
add_subdirectory(python)


if(BUILD_TESTING)
# Make sure to fetch all data, after all legacy test cases have been added
ExternalData_Add_Target(legacy_test_cases)
endif()
#--- add CMake infrastructure --------------------------------------------------
include(cmake/podioCreateConfig.cmake)
8 changes: 0 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ PODIO_ADD_ROOT_IO_DICT(ExtensionDataModelDict ExtensionDataModel "${ext_headers}

PODIO_ADD_SIO_IO_BLOCKS(ExtensionDataModel "${ext_headers}" "${ext_sources}")

include(ExternalData)
list(APPEND ExternalData_URL_TEMPLATES
"https://key4hep.web.cern.ch:443/testFiles/podio/%(hash)"
)


# Add a legacy test case based on a base executable and a version for which an
# input file exists
macro(ADD_PODIO_LEGACY_TEST version base_test input_file)
Expand Down Expand Up @@ -99,6 +93,4 @@ endif()
# Customize CTest to potentially disable some of the tests with known problems
configure_file(CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY)

ExternalData_Add_Target(legacy_test_cases)

message(STATUS "Test inputs will be stored in: ${ExternalData_OBJECT_STORES} if they are not already present")
34 changes: 25 additions & 9 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,40 @@ if(BUILD_TESTING)
endif()
endfunction()

# Helper function for easily creating "tests" that simply execute podio-dump
# with different arguments on legacy input files. Not crashing is considered
# success.
#
# Args:
# name the name suffix of the test (the actual name will be assembled)
# version the legacy version of the input
# input_file the input file to use
function(CREATE_LEGACY_DUMP_TEST name version input_file)
set(_name podio-dump-legacy_${name}_${version})
ExternalData_Add_Test(legacy_test_cases
NAME ${_name}
COMMAND ./podio-dump ${ARGN} DATA{${PROJECT_SOURCE_DIR}/tests/input_files/${input_file}}
)
PODIO_SET_TEST_ENV(${_name})

set_tests_properties(${_name} PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
endfunction()

CREATE_DUMP_TEST(podio-dump-help _dummy_target_ --help)
CREATE_DUMP_TEST(podio-dump-root "write_frame_root" ${PROJECT_BINARY_DIR}/tests/root_io/example_frame.root)
CREATE_DUMP_TEST(podio-dump-detailed-root "write_frame_root" --detailed --category other_events --entries 2:3 ${PROJECT_BINARY_DIR}/tests/root_io/example_frame.root)


if (DEFINED CACHE{PODIO_TEST_INPUT_DATA_DIR})
CREATE_DUMP_TEST(podio-dump-root-legacy "" ${PODIO_TEST_INPUT_DATA_DIR}/v00-16-06/example.root)
CREATE_DUMP_TEST(podio-dump-detailed-root-legacy "" --detailed --entries 2:3 ${PODIO_TEST_INPUT_DATA_DIR}/v00-16-06/example.root)
endif()
CREATE_LEGACY_DUMP_TEST("root" v00-16-06 v00-16-06-example.root)
CREATE_LEGACY_DUMP_TEST("root-detailed" v00-16-06 v00-16-06-example.root --detailed --entries 2:3)

if (ENABLE_SIO)
CREATE_DUMP_TEST(podio-dump-sio "write_frame_sio" --entries 4:7 ${PROJECT_BINARY_DIR}/tests/sio_io/example_frame.sio)
CREATE_DUMP_TEST(podio-dump-detailed-sio "write_frame_sio" --detailed --entries 9 ${PROJECT_BINARY_DIR}/tests/sio_io/example_frame.sio)

if (DEFINED CACHE{PODIO_TEST_INPUT_DATA_DIR})
CREATE_DUMP_TEST(podio-dump-sio-legacy "" ${PODIO_TEST_INPUT_DATA_DIR}/v00-16-06/example.sio)
CREATE_DUMP_TEST(podio-dump-detailed-sio-legacy "" --detailed --entries 2:3 ${PODIO_TEST_INPUT_DATA_DIR}/v00-16-06/example.sio)
endif()
CREATE_LEGACY_DUMP_TEST("sio" v00-16-06 v00-16-06-example.sio)
CREATE_LEGACY_DUMP_TEST("sio-detailed" v00-16-06 v00-16-06-example.sio --detailed --entries 2:3)
endif()

if (ENABLE_RNTUPLE)
Expand Down

0 comments on commit 1a04d1a

Please sign in to comment.