Skip to content

Commit

Permalink
Skip catch test discovery if environment requires it (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored Sep 11, 2023
1 parent cb92d6c commit ae3132c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,31 @@ include(Catch)
add_executable(unittests
test_kinematics.cpp test_vector_utils.cpp)
target_link_libraries(unittests edm4hep EDM4HEP::utils Catch2::Catch2 Catch2::Catch2WithMain)
catch_discover_tests(unittests)

option(SKIP_CATCH_DISCOVERY "Skip the Catch2 test discovery" OFF)

# To work around https://github.com/catchorg/Catch2/issues/2424 we need the
# DL_PATH argument for catch_discoer_tests which requires CMake 3.22 at least
# The whole issue can be avoied if we skip the catch test discovery and set the
# environment on our own
if (CMAKE_VERSION VERSION_LESS 3.22)
set(SKIP_CATCH_DISCOVERY ON)
endif()

if (SKIP_CATCH_DISCOVERY)
# Unfortunately Memory sanitizer seems to be really unhappy with Catch2 and
# it fails to succesfully launch the executable and execute any test. Here
# we just include them in order to have them show up as failing
add_test(NAME unittests COMMAND unittests)
set_property(TEST unittests
PROPERTY ENVIRONMENT
LD_LIBRARY_PATH=$<TARGET_FILE_DIR:edm4hep>:$<TARGET_FILE_DIR:podio::podio>:$<TARGET_FILE_DIR:ROOT::Core>:$ENV{LD_LIBRARY_PATH}
PYTHONPATH=${PROJECT_SOURCE_DIR}/python:$ENV{PYTHONPATH}
ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/edm4hep:${PROJECT_SOURCE_DIR}/utils/include:$ENV{ROOT_INCLUDE_PATH}
)
else()
catch_discover_tests(unittests)
endif()

add_test(NAME pyunittests COMMAND python -m unittest discover -s ${CMAKE_CURRENT_LIST_DIR})
set_property(TEST pyunittests
Expand Down

0 comments on commit ae3132c

Please sign in to comment.