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

Added new DL_PATHS option to catch_discover_tests() #2467

Merged

Conversation

mheimlich
Copy link
Contributor

Description

This enables setting required PATH/LD_LIBRARY_PATH environment variables both when retrieving the list of test cases and when executing the tests.

Some test executables depend on shared libraries and thus can only be launched when the dynamic linker can find their dependencies. With set_tests_properties() it is possible to extend PATH/LD_LIBRARY_PATH with the ENVIRONMENT property of a test. Unfortunately this does not work with the PROPERTIES parameter of catch_discover_tests() (especially on Windows because of the ; seperator).

At first I tried integrating this by parsing said ENVIRONMENT property but ultimately failed due to both my and the cmake language limitations. So I implemented this as a new parameter, which makes it easier to handle the list of paths.

I did not find any existing tests for catch_discover_tests(), so I did not extend/add one for this. If there is one, please point me in the right direction and I'll add one.

…tion.

This enables setting the required PATH/LD_LIBRARY_PATH environment variables both when retrieving the list of text cases and when executing the tests.
@codecov
Copy link

codecov bot commented Jun 24, 2022

Codecov Report

Merging #2467 (3828106) into devel (8730260) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##            devel    #2467   +/-   ##
=======================================
  Coverage   91.49%   91.49%           
=======================================
  Files         181      181           
  Lines        7519     7519           
=======================================
  Hits         6879     6879           
  Misses        640      640           

@horenmar horenmar added Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration. labels Jul 11, 2022
@horenmar
Copy link
Member

There aren't any tests for catch_discover_tests. If someone wanted to add them I would merge them, but adding them is very low on my own priority list.

extras/Catch.cmake Outdated Show resolved Hide resolved
@horenmar
Copy link
Member

Thanks, this looks reasonable enough.

@horenmar horenmar merged commit a63ad74 into catchorg:devel Jul 11, 2022
@mchapman87501
Copy link

Thanks for adding DL_PATHS!
Unfortunately, I'm having trouble getting it to work on macOS. When running on macOS, I believe CatchAddTests.cmake needs to set DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH.

@mheimlich
Copy link
Contributor Author

@mchapman87501 I have adapted it to use DYLD_LIBRARY_PATH on Apple plaftorms in https://github.com/mheimlich/Catch2/tree/catch_discover_macos
Please test if this works for you, then I'll open a pull request here.

@mchapman87501
Copy link

This works. Thank you!

I've attached a small project to demonstrate the problem and to show that the fix works.
Apologies in advance: it's fragile. Among other things it uses homebrew's Catch2 -- whatever version is current as of today -- to demonstrate the failure case.

demo_catch2_dl_path.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants