Skip to content

fix: ensure tests get valid LD_LIBRARY_PATH and JANA_PLUGIN_PATH#505

Open
wdconinc wants to merge 1 commit into
JeffersonLab:masterfrom
wdconinc:test-env
Open

fix: ensure tests get valid LD_LIBRARY_PATH and JANA_PLUGIN_PATH#505
wdconinc wants to merge 1 commit into
JeffersonLab:masterfrom
wdconinc:test-env

Conversation

@wdconinc
Copy link
Copy Markdown
Member

This PR ensures that the test environment gets the correct (build-time) LD_LIBRARY_PATH and JANA_PLUGIN_PATH so tests don't use stale installed versions.

Copilot AI review requested due to automatic review settings May 28, 2026 00:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates CMake/CTest configuration so plugin- and library-related tests can run successfully from the build tree by setting runtime environment variables and aligning output locations.

Changes:

  • Adds ENVIRONMENT to multiple add_test() entries to set JANA_PLUGIN_PATH and LD_LIBRARY_PATH.
  • Adjusts plugin library output directory to a consistent build-tree plugins folder.
  • Updates add_jana_test/add_jana_library/add_jana_plugin macros to attach runtime environment configuration to tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/plugins/janadot/CMakeLists.txt Sets test environment so janadot plugin tests can find plugins/libs in build tree
src/plugins/JTest/CMakeLists.txt Sets test environment so JTest can find plugins/libs in build tree
src/examples/tutorial_with_lightweight_datamodel/05_csv_file_writer/CMakeLists.txt Uses built jana target for the test and sets env for plugin/lib discovery
src/examples/tutorial_with_lightweight_datamodel/02_random_hit_source/CMakeLists.txt Sets env for plugin/lib discovery for the example smoketest
src/examples/misc/Tutorial/CMakeLists.txt Sets env for plugin/lib discovery for the example test
src/examples/misc/TimesliceExample/CMakeLists.txt Sets env for plugin/lib discovery for PODIO-dependent example tests
src/examples/misc/RootDatamodelExample/CMakeLists.txt Adds env even though the test is disabled, keeping configuration consistent
src/examples/misc/EventGroupExample/CMakeLists.txt Sets env for plugin/lib discovery for the example test
src/examples/misc/DstExample/CMakeLists.txt Sets env for plugin/lib discovery for the example test
cmake/AddJanaTest.cmake Changes test command invocation and sets LD_LIBRARY_PATH for tests
cmake/AddJanaPlugin.cmake Sets plugin library output dir and attaches env to plugin tests
cmake/AddJanaLibrary.cmake Attaches LD_LIBRARY_PATH env to library tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/AddJanaTest.cmake
install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)

add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${test_target_name})
add_test(NAME ${test_target_name} COMMAND ${test_target_name})
Comment thread cmake/AddJanaPlugin.cmake
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/JANA/plugins"
Comment on lines +104 to +106
set_tests_properties(${library_name}_tests PROPERTIES
ENVIRONMENT "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:${library_name}>:$<TARGET_FILE_DIR:jana2_shared_lib>:$ENV{LD_LIBRARY_PATH}"
)
Comment on lines 13 to +18
add_test(NAME examples-lw-00-smoketest COMMAND jana -Pplugins=lw_random_hit_source -Pjana:nevents=10)

set_tests_properties(examples-lw-00-smoketest PROPERTIES LABELS "examples")
set_tests_properties(examples-lw-00-smoketest PROPERTIES
LABELS "examples"
ENVIRONMENT "JANA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/JANA/plugins;LD_LIBRARY_PATH=$<TARGET_FILE_DIR:jana2_shared_lib>:$ENV{LD_LIBRARY_PATH}"
)
Comment on lines 10 to 16
COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana -Pplugins=TimesliceExample -Puse_timeslices=0 -Pjana:nevents=10 events.root)
set_tests_properties(jana-example-timeslices-simple-tests PROPERTIES
ENVIRONMENT "JANA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/JANA/plugins;LD_LIBRARY_PATH=$<TARGET_FILE_DIR:jana2_shared_lib>:$ENV{LD_LIBRARY_PATH}"
)

add_test(NAME jana-example-timeslices-complex-tests
COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana -Pplugins=TimesliceExample -Puse_timeslices=1 -Pjana:nevents=10 timeslices.root)
Comment on lines +7 to +8
set_tests_properties(jana-plugin-jtest-tests PROPERTIES
ENVIRONMENT "JANA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/JANA/plugins;LD_LIBRARY_PATH=$<TARGET_FILE_DIR:jana2_shared_lib>:$ENV{LD_LIBRARY_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants