-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel coverage fails on existing rules_go test #6293
Comments
This is failing in 0.18.0 now. :( |
I believe the workaround is throw a dummy implicit
|
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
@benjaminp Thanks, I think that will get rules_go's CI to be green again. I'll leave this issue open, since it's still a regression. |
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
When collecting coverage, Bazel now expects test rules to have an implicit "$lcov_merger" or "_lcov_merger" attribute that points to a binary to be run by the test driver script. This change adds a dummy _lcov_merger attribute to go_test. The script does nothing for now. Related bazelbuild/bazel#6293
Summary: From bazel 0.18.0, an lcov_merger tool is needed for every test rule that collects coverage. See bazelbuild/bazel#6293 for more details. Reviewers: ysaito Reviewed By: ysaito Differential Revision: https://phabricator.grailbio.com/D20750 fbshipit-source-id: f480a5e
@jayconrod @benjaminp Addressing the questions from #8670.
Bazel does need a tool to merge lcov files from multiple tests, but that is not /usr/bin/lcov. Bazel uses an embedded tool called
lcov is only needed for C++ tests and is not required for the other languages. For C++ lcov will be needed in the future.
Currently bazel assumes that all test runs generate an lcov file in coverage mode, so they should have an
I wouldn't say this is a thing that needs to be fixed. Reiterating, How does go coverage work with go_test? What does it generate and what role does bazel play here? |
So I think the long term solution for this is for I'm not sure what we should do in the short term. Is there a way we can keep writing non-lcov coverage data to |
My problem is that if you have a coverage-enabled test and don't define a |
Thanks @jayconrod @benjaminp for your explanations! Answers inline below.
I agree this should be the long term solution and fits well with #5885.
This depends on the design of the Starlark mechanism for coverage. My initial idea was for every language to define a tool that converts from their format to lcov so that we can have consistency across the rules sets.
You can still do that for the foreseeing future.
That would go against standardizing bazel's coverage output. Even if it's possible right now to output different formats in COVERAGE_OUTPUT_FILE we'd still like to keep moving towards a standard. |
What if the rule can produce lcov output natively without the help of lcov merger? The current situation is that Bazel tries to invoke a tool that it purposely didn't add as an input to the test. That's not a useful behavior. |
Especially if your rule produces lcov natively you should specify the lcov merger tool. If your test generates multiple lcov reports then lcov_merger can find and merge them.
Bazel fails the coverage run if it doesn't find lcov-merger. The behaviour when bazel was invoking |
What the see is that if coverage collection is enabled for a target, Bazel preprends |
@lberki I think this can be closed. Starlark rules can now add the required dependency in the following way without incurring any overhead for "_lcov_merger": attr.label(
default = configuration_field(fragment = "coverage", name = "output_generator"),
cfg = "exec",
) rules_go emits lcov that is then picked up by the merger tool. |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
Description of the problem / feature request:
In Bazel 0.18.0rc8, the rules_go target
//tests/core/coverage:coverage_test
fails. It passed in 0.17.1. It appears the collect_coverage.sh script is failing because theLCOV_MERGER
environment variable is not set.This may affect all coverage runs for Starlark runs.
coverage_test
is a trivialgo_test
used to collect coverage data; there's nothing special about it.Snippet of the output:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
master
(currently00a664876d6300951e7fa8766e0dfd42cdac67ad
).bazel coverage //tests/core/coverage:coverage_test
What operating system are you running Bazel on?
Linux 4.17.0-3rodete2-amd64 #1 SMP Debian 4.17.17-1rodete2 (2018-08-28) x86_64 GNU/Linux
What's the output of
bazel info release
?release 0.18.0rc8
Any other information, logs, or outputs that you want to share?
I have lcov installed at /usr/bin/lcov. Not sure if that makes a difference now -- it did in the past.
The text was updated successfully, but these errors were encountered: