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

inconsistent semicolon expansion in catch_discover_tests #2214

Closed
georg-emg opened this issue Apr 13, 2021 · 3 comments · Fixed by #2215
Closed

inconsistent semicolon expansion in catch_discover_tests #2214

georg-emg opened this issue Apr 13, 2021 · 3 comments · Fixed by #2215
Labels
Extras Touches utility scripts outside of Catch2 proper, e.g. CMake integration.

Comments

@georg-emg
Copy link
Contributor

georg-emg commented Apr 13, 2021

When using the cmake command catch_discover_tests on a target with a property CROSSCOMPILING_EMULATOR, catch2 will use the emulator to discover and execute tests. If one of the parameters of the cross compiling emulator contains an escaped semicolon, however, the behaviour is inconsistent between the test discovery and the test execution. When running the test app to discover the tests, escaped semicolons are correctly turned into plain semicolons. When the tests are then run using ctest, however, escaped semicolons are falsely interpreted as separators between individual command line parameters.

Example:

consider the following cmake code fragment for a Windows test app:

add_executable(myTestApp test.cpp)
set_target_properties(myTestApp PROPERTIES CROSSCOMPILING_EMULATOR "${CMAKE_COMMAND};-E;env;PATH=C:\SomeDirectory\;C:\SomeOtherDirectory")
catch_discover_tests(myTestApp)

This will run myTestApp.exe as:

cmake.exe -E env PATH=C:\SomeDirectory;C:\SomeOtherDirectory myTestApp.exe --list-test-names-only

however, the generated include file myTestApp_tests-xxxxxxx.cmakethat contains the cmake tests, will contain lines in the form:

add_test(some_test_name cmake.exe -E env [==[PATH=C:\SomeDirectory]==] [==[C:\SomeOtherDirectory]==] myTestApp.exe some_test_name)
#                                                                     ^ Note the wrongly split argument here

instead of:

add_test(some_test_name cmake.exe -E env [==[PATH=C:\SomeDirectory;C:\SomeOtherDirectory]==] myTestApp.exe some_test_name)
#                                                                 ^ There should be a semicolon like shown here
@Minoru
Copy link
Contributor

Minoru commented Apr 16, 2021

This issue is mentioned in the changelog for 2.13.6, but the PR that fixed it (#2215) is actually merged into develop branch, not 2.x, so the fix is absent from 2.13.6 release. No big deal (to me), just letting you know, @horenmar.

@horenmar
Copy link
Member

@Minoru Thanks, but the fix is merged into v2 via #2216. However the discussion for the fix was in #2215, so I linked that one in the release notes.

@Minoru
Copy link
Contributor

Minoru commented Apr 17, 2021

Ah, sorry, my bad! I failed to realize this is related to CMake, not the hpp file.

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 a pull request may close this issue.

3 participants