-
Notifications
You must be signed in to change notification settings - Fork 137
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
Measure test coverage and report to codecov.io #193
Conversation
Codecov Report
@@ Coverage Diff @@
## master #193 +/- ##
=========================================
Coverage ? 75.21%
=========================================
Files ? 45
Lines ? 15409
Branches ? 0
=========================================
Hits ? 11590
Misses ? 3819
Partials ? 0 Continue to review full report at Codecov.
|
Please beware that the autogenerated coverage comparison in the comment above is somewhat meaningless, as the testing metrics aren't yet determined for the master branch. EDIT: If desired, we can disable automatic codecov comments in PRs such as the one above by adding a |
@anders-dc Thanks! This is very cool. I don't understand what I'm looking at, though. In the code files, there are lots of instances like this
How can the line extension be hit and the beginning of the statement not be hit? |
Hi Elizabeth,
You will see the same pattern if af IF statement conditional evaluates to false. I’ll look up on the question on unmarked/white lines of code. EDIT: Oh, I might have misunderstood your example. Let me get back to you later. |
It is worth looking at the gcov documentation if the codecov documentation is lacking depth. Codecov is just a frontend, and for GCC-compiled languages parses whatever gcov produces into html. The gcov results can be inspected directly from a local build by running Here is my take on the white lines. These are typically declarations of functions or variables, or some other syntax component which after a successful compilation will not cause failure. Therefore, they are not counted as part of the coverage metric. Finally, it seems there is a consistent problem with continuation characters ( |
I'm wondering if setting this up with travis is the best way. We will always have a highly limited ability to test on travis due to the pe counts and the goal to have relatively short turnaround (30 min max I'd say). Ideally, I think we'd want to apply the code coverage tool to a large test suite on a non travis machine to get a better idea where we stand. Nothing wrong (except maybe the reduction in optimization) with doing this on travis, although not clear we gain much by doing it all the time on travis. I see value in using this tool occasionally to measure our test coverage on a machine where we can run our full test suite. What would be the best way to do that? Would it be to define a flag (like DEBUG) in the test suite so we can turn on the code coverage flags and then have it ping codecov.io tool? In fact, maybe DEBUG should also turn on the code coverage compiler options tool since it needs -O0. Does this work only with gnu or also other compilers? |
Okay, so gcov is clever enough to treat lines with continuation characters as one statement. However, it seems that information is lost when results from different tests are combined and uploaded to codecov. |
Good point @apcraig. Icepack would probably work better than the more intensive test suite of CICE. The current It is totally possible to generate the results locally as needed, and upload to codecov using a token. I do not have experience with compilers other than GCC for this, sorry. |
Thanks @anders-dc. So what is the best way to proceed? Should we back off the travis compiler changes and think about implementing this more generally. It looks like all we need is the right compiler switches and then the "after success" code to trigger the coverage analysis and tool. Do you have access to a machine that would allow you to prototype this. If not, I'm happy to do it now that you've figured it out. :) I think it's still good to switch to gcc regardless. |
Sounds good to me. Let me wrap up the entire functionality in a script, where the codecov token is assumed to be defined in an environment variable. I'll update this PR shortly. |
Could you sign up with CICE-Consortium for codecov if you haven't already? Also, please send me the repository token. |
I granted access to CICE-Consortium at https://codecov.io/login/gh. Is that what is needed? The |
Thank you Elizabeth. During the testing telecon it was decided that I will try and implement the code coverage reporting as a flag to the |
Hi @anders-dc, just a quick follow up from discussions earlier. This is what I would propose. A new variable in cice.settings called ICE_CODECOV or something like that. It would be false by default and then add a set_env.codecov to the options directory that would set it to true. Then, this option is available in an individual test by setting -s codecov or in a test suite by using -s codecov. We will have to verify that when running a test suite, the -s option set on the command line "adds" to the options specified in the test suite, but I believe it does. Then we just need to modify the Macros files (all or some) so when ICE_CODECOV is true, a new set of flags is triggered. We will need to make sure that works with DEBUG TRUE and FALSE and so forth as well. Let me know if that makes sense. Maybe you have a better approach, if so, please feel free to do that. |
Hi @apcraig, that makes a lot of sense! I think we may even be able to avoid modifying the Macros for the build environments. If |
Hi @anders-dc, what's the status of this PR? Are you waiting for me? Should we move this discussion to an issue and close the PR? No rush, just trying to keep track of things and also wondering if I dropped a ball. thanks. |
hi @apcraig, sorry for the silence. You are not holding up anything. Let's close this PR, and I will put in a new one with the discussed changes within the next two weeks. |
Test-coverage reporting
This pull request introduces coverage metrics for
travis_suite
, and submits them to codecov.io. See an example for Icepack here. The overview shows what lines of source code are "hit" by the test suite, and which are not. The coverage metrics are submitted to codecov.io if the build succeeds.In order to obtain accurate testing metrics, the Travis runs run without optimizations (flag
-O0
). Therefore, the test suite may take slightly longer to complete from now on.Steps required for CICE-Consortium
Someone with ownership of the Github user CICE-Consortium needs to sign up to codecov.io with the Github user. Afterwards, this person needs to enable the Icepack repository on the codecov page. You may want to enable the CICE repository right away as well. We do not need the token that is generated.
Other changes in this PR
I transitioned from clang to GCC for linking purposes on Travis-CI (like I did with CICE). This should have no practical implications.
Developer(s): Anders Damsgaard, Princeton/NOAA-GFDL (github.com/anders-dc, adamsgaard.dk)
Are the code changes bit for bit, different at roundoff level, or more substantial? There are no changes to the underlying code.
Is the documentation being updated with this PR? (Y/N) No.
If not, does the documentation need to be updated separately? (Y/N) No.