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

Rework CMake test discovery #1673

Merged
merged 8 commits into from Nov 15, 2022
Merged

Rework CMake test discovery #1673

merged 8 commits into from Nov 15, 2022

Conversation

thetic
Copy link
Contributor

@thetic thetic commented Nov 12, 2022

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.

$ cmake --preset MSVC
$ cmake --build cpputest_build --config Release
$ ctest --test-dir cpputest_build -C Debug

These changes eliminate the need for the "path normalization" that prevents outputs from multiple configs from coexisting.

@coveralls
Copy link

coveralls commented Nov 12, 2022

Coverage Status

Coverage remained the same at 99.625% when pulling 73fa9fb on thetic:discovery-zone into 63f0450 on cpputest:master.

@@ -4,6 +4,10 @@ set(_DISCOVER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/../Scripts/CppUTestBuildTimeDisc

# Create target to discover tests
function (cpputest_buildtime_discover_tests tgt)
Copy link
Contributor Author

@thetic thetic Nov 12, 2022

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.

@thetic thetic changed the title Refresh CMake test discovery Rework CMake test discovery Nov 12, 2022
@@ -1,10 +0,0 @@
# Override output properties to put test executable at specificied location
Copy link
Contributor Author

@thetic thetic Nov 12, 2022

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

@thetic thetic mentioned this pull request Nov 12, 2022
@basvodde
Copy link
Member

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.
@basvodde basvodde merged commit f201677 into cpputest:master Nov 15, 2022
@thetic thetic deleted the discovery-zone branch November 15, 2022 17:24
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.

None yet

3 participants