ParseAndAddCatchTests: Ignore cmake object libraries#1601
Merged
horenmar merged 1 commit intocatchorg:masterfrom Apr 14, 2019
v1tzl1:master
Merged
ParseAndAddCatchTests: Ignore cmake object libraries#1601horenmar merged 1 commit intocatchorg:masterfrom v1tzl1:master
horenmar merged 1 commit intocatchorg:masterfrom
v1tzl1:master
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1601 +/- ##
=======================================
Coverage 80.72% 80.72%
=======================================
Files 121 121
Lines 3424 3424
=======================================
Hits 2764 2764
Misses 660 660 |
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #1601 +/- ##
=======================================
Coverage 80.72% 80.72%
=======================================
Files 121 121
Lines 3424 3424
=======================================
Hits 2764 2764
Misses 660 660 |
Member
|
Thanks, the changes look good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR will make the ParseAndAddCatchTests function ignore any "files" that match
\$<TARGET_OBJECTS:.+>, so when you use cmake object libraries the script will not try to parse that "file" for the Catch2 TEST_CASE macros.I am putting file in quotes here because in the case of object libraries this is clearly a cmake variable and not a file.
Why
I am using a cmake object library to compile the sources of my target binary and re-use them in my Catch2 unittests without recompiling them.
This will give the following warnings (PARSE_CATCH_TESTS_VERBOSE is set during cmake configuration)
While the parser will keep working and finding all my tests, I don't want to have warnings in my cmake runs. With the proposed change the output will look like this:
Note that this does not change the behaviour of Catch2. Before it ignored the "file" because it could not find it on the file system, now it skips all files that look like object library variables before checking that the remaining files are actually there. There is also an output to
ParseAndAddCatchTests_PrintDebugMessageso the behaviour can be traced if there ever is a problem with this.Possible side effects
With this change, any tests defined in a file which's name matches
\$<TARGET_OBJECTS:.+>will no longer be detected.I have tested these changes locally with cmake 3.9.6 on Linux, but since the change is minimal there should not be much issues with other systems. For the sake of completeness I also ran the tests described in /docs/contributing.md which all passed.
Edit: removed some double copy lines from the output and fixed some typos.