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
Rework CMake test discovery #1673
Conversation
@@ -4,6 +4,10 @@ set(_DISCOVER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/../Scripts/CppUTestBuildTimeDisc | |||
|
|||
# Create target to discover tests | |||
function (cpputest_buildtime_discover_tests tgt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to create a new module rather than refactoring the existing one. Their behavior is not the same. When using cpputest_buildtime_discover_tests
with a multi-config project, ctest runs tests regardless of whether and which config it is passed. When using cpputest_discover_tests
with such a project, ctest requires a config to be passed. This is the more "normal" behavior that mimics the native add_test
command.
I don't know the workflow for breaking changes, but this should be deleted eventually, ideally prior to the next major release.
f4ed527
to
74df43e
Compare
@@ -1,10 +0,0 @@ | |||
# Override output properties to put test executable at specificied location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This created collisions between configs by using the same output path for all of them:
cmake --preset MSVC
cmake --build cpputest_build --config Release
cmake --build cpputest_build --config Debug # Overwrites Release outputs
ctest --test-dir cpputest_build -C Release # Actually runs Debug tests
Uhm, the PR has a conflict |
This is broken for multi-configuration generators. Debug and release builds, for example, need to output to different paths and run tests against those paths. The current implementation would overwrite one config's build with another and test that one, regardless of the config the user is trying to test.
74df43e
to
c781ff8
Compare
c781ff8
to
73fa9fb
Compare
The existing implementation does not handle multi-config setups (generators that can build Debug, Release, etc. from the same project like Visual Studio).
Consider the following example. No tests should run because Debug hasn't been built. The current discovery automation, however, just runs whatever was built last.
These changes eliminate the need for the "path normalization" that prevents outputs from multiple configs from coexisting.