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

Fix code coverage test #262

Merged
merged 14 commits into from
Aug 17, 2020
Merged

Fix code coverage test #262

merged 14 commits into from
Aug 17, 2020

Conversation

JoshuaSBrown
Copy link
Collaborator

@JoshuaSBrown JoshuaSBrown commented Aug 10, 2020

PR Summary

This fixes the problem raised by @pgrete where code coverage tests were being run when the CODE COVERAGE flag was disabled.

If you follow the commits, there are two solutions, the first makes use of cmake config variables that are inserted into the .cpp files. I am not a fan of this solution because it feel clunky, and it means treating all the unit tests files as config files.

The second solution is much more elegant, but requires bumping the cmake version to 3.12. This one does not require changes to any of the cpp source files. Instead it parses the tests after Catch2 has created them and appends a coverage label to any tests that does not contain the performance label.

#254

PR Checklist

  • Code passes cpplint
  • Code is formatted

@JoshuaSBrown JoshuaSBrown linked an issue Aug 10, 2020 that may be closed by this pull request
@JoshuaSBrown JoshuaSBrown added bug Something isn't working testing labels Aug 10, 2020
@JoshuaSBrown JoshuaSBrown self-assigned this Aug 10, 2020
@pgrete
Copy link
Collaborator

pgrete commented Aug 11, 2020

Did you confirm that this fully addresses the issue?
I'm still getting that label (coverage) based split between tests.

@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #262 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #262   +/-   ##
========================================
  Coverage    51.92%   51.92%           
========================================
  Files           95       95           
  Lines         9904     9904           
========================================
  Hits          5143     5143           
  Misses        4761     4761           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5979a09...7398a76. Read the comment docs.

@JoshuaSBrown
Copy link
Collaborator Author

JoshuaSBrown commented Aug 11, 2020

Did you confirm that this fully addresses the issue?
I'm still getting that label (coverage) based split between tests.

Without the coverage flag I get this:

[ppc64le] [joshuasbrown@cn2023 build]$ ctest -R coverage
Test project /home/joshuasbrown/Software/parthenon_x86_64/parthenon/build
No tests were found!!!

@JoshuaSBrown
Copy link
Collaborator Author

Ok, I see what you are getting at, it will be hard to remove the labels from the unit tests because they are added in the actual cpp files not in cmake. The way Catch2 is setup they the labels are parsed in through the TEST_CASE macro in the cpp files, I can see if the coverage label can instead be added through cmake.

@JoshuaSBrown
Copy link
Collaborator Author

This works, I had hoped there was a better way to do this, the problem is that the only way to add labels that I can see to catch2 tests is within the .cpp files, I had hoped to use compile definitions but because the catch2 macros that resolve the labels are also handled by the preprocessor the labels are not correctly resolved by doing this. I'm still open to better ways of doing this.

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this solution, but I don't see a better one. If it fixes things, I say we merge it in and don't nitpick. Thanks for digging in and finding a fix.

One potential solution, which I shudder to consider, would be using a text processing like sed or awk. I do not advocate it though---I think the cmake solution is better for us.

@Yurlungur
Copy link
Collaborator

@JoshuaSBrown looks like formatting check is failing. A make format or a call to par-hermes will probably fix it.

@JoshuaSBrown
Copy link
Collaborator Author

@par-hermes format

@JoshuaSBrown
Copy link
Collaborator Author

I don't love this solution, but I don't see a better one. If it fixes things, I say we merge it in and don't nitpick. Thanks for digging in and finding a fix.

One potential solution, which I shudder to consider, would be using a text processing like sed or awk. I do not advocate it though---I think the cmake solution is better for us.

I have now improved it, I like this implementation much more too.

Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now improved it, I like this implementation much more too.

Aha! Yes, this is a massive improvement. Does any documentation need to change? On a first pass, I think no.

@JoshuaSBrown
Copy link
Collaborator Author

JoshuaSBrown commented Aug 12, 2020

I have now improved it, I like this implementation much more too.

Aha! Yes, this is a massive improvement. Does any documentation need to change? On a first pass, I think no.

Thanks! And yes, I need to update some documentation, I want to make sure no one has issues with bumping the cmake version though before proceeding. If the Athena++ guys are ok with this the cmake version used in the ci will also need to be updated.

@pgrete
Copy link
Collaborator

pgrete commented Aug 14, 2020

I agree. This approach looks way cleaner (and a first step towards cleaning up the testing infrastructure).
Feel free to bump the cmake version in both CI files. If I didn't miss anything using 3.12.4 should work in both cases out of the box.

@JoshuaSBrown
Copy link
Collaborator Author

@AndrewGaspar Do I have your approval to merge this?

CMakeLists.txt Outdated Show resolved Hide resolved
@AndrewGaspar AndrewGaspar merged commit 37ee9d4 into develop Aug 17, 2020
@AndrewGaspar AndrewGaspar deleted the JoshuaSBrown/fix-code-cov-test branch August 17, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior for coverage tests
4 participants