-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Generate coverage reports in LCOV format #3117
Conversation
494c47f
to
bf17ad3
Compare
@achew22 Would you be available to review this new feature? |
415e74b
to
31c45df
Compare
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.
Only went half way through the PR. I will pick it up later this week.
@linzhp I pushed one commit that addresses your comments and another one that removes the branch coverage information - it may be misleading and made the PR unnecessarily complicated. |
I think you'll need to update https://github.com/bazelbuild/rules_go/blob/master/tests/core/coverage/coverage_test.go to validate both the lcov and the old (gcov?) coverage formats, but then I'd be happy with this PR. |
@achew22 Should I also update docs? If so, which ones? |
I just went through the repo and didn't see any documentation that I think needs to be update. There might need to be some changes made to the nogo coverage test as well, but if it passes I'm happy to merge |
@achew22 I made the changes to the tests and also updated the message of the first commit. |
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.
The logic looks good to me. Thanks for working on this.
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.
We are getting close
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.
LGTM. @achew22 feel free to merge if you don't have more concerns.
The generated TestMain now converts the go cover coverage reports to LCOV. When combined with Bazel's --combined_report=lcov, this makes Go coverage show up in cross-language, cross-target coverage reports by default. The combined report can be converted to HTML via e.g. genhtml bazel-out/_coverage/_coverage_report.dat If the old behavior of generating cover reports is still desired, it can be enabled via: --@io_bazel_rules_go//go/config:cover_format="go_cover"
It's strange that lcov cannot be produced in Uber's Go monorepo after applying this onto the master of rules_go:
|
@linzhp Did you try this with |
I only try it in one single test (running |
Depending on the source structure, the instrumentation filter may be off. Do you get reports with |
The instrumentation filter is on:
I also tried:
|
Which Bazel version are you using at Uber? Could you share any bits of the test log that do not originate in your own code? Maybe there is some helpful output there. |
We are using Bazel 5.1.0. The test.log is like:
The testlog directory of that test is like:
|
@linzhp Could you post the |
Are you on Bazel Slack? |
I also tried removing this |
A problem is the |
eed987d
to
2f3f3bb
Compare
Just a note: The current minimum supported version of Go with |
|
WRT the
Curious about this comment. Do you have a link to go with it? I'd like to see what |
It got added in golang/go@4f76fe8 |
@fmeum Can you review @abhinav 's improvement on this PR? |
This makes it implementation specific but obviates the need to have a copy of the testDeps interface. While at it, rename PatchTestDeps to LcovTestDeps since this is lcov-specific.
We don't need this interface if we can use testdeps.TestDeps directly.
rename and move to the bottom of the file
The comment stated that the function was called with 'true' before m.Run returns, but it's the opposite: it's called with true before running tests, and with false after.
Thanks for the great improvements, @abhinav. I somehow thought that the testdeps package couldn't be referenced from a non-main package since it's under |
Summary: rules_go reports coverage in LCOV format by default as of version 0.32.0 See bazel-contrib/rules_go#3146 and bazel-contrib/rules_go#3117 So the coverage script was no longer doing the correct thing. This fixes the script. Test Plan: Ran the coverage script locally, generated an HTML report. Ensured that we see cpp, go and js coverage. Reviewers: zasgar, michelle Reviewed By: zasgar Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D12345 GitOrigin-RevId: 6f4ff98f66fedd68e44f04954688c3efa95616b4
What type of PR is this?
What does this PR do? Why is it needed?
With the new
--//go/config:cover_format
flag set tolcov
, go cover coverage reports are converted to lcov. When combined with Bazel's--combined_report=lcov
, this allows for Go coverage to show up in cross-language, cross-target coverage reports.The combined report can be converted to HTML via e.g.
Which issues(s) does this PR fix?
Fixes #140
Other notes for review
I haven't added anything to the user-facing docs yet, but will do so before this is merged.