Repository navigation
Description
Description of the problem / feature request:
Running bazel coverage --combined_report=lcov //... results in a NullPointerException
> bazel coverage --combined_report=lcov //...
INFO: Using default value for --instrumentation_filter: "//src/main/java/com/chris[/:]".
INFO: Override the above default with --instrumentation_filter
Internal error thrown during build. Printing stack trace: java.lang.NullPointerException
at com.google.devtools.build.lib.bazel.coverage.BazelCoverageReportModule$1.getArgs(BazelCoverageReportModule.java:108)
at com.google.devtools.build.lib.bazel.coverage.CoverageReportActionBuilder.generateCoverageReportAction(CoverageReportActionBuilder.java:244)
at com.google.devtools.build.lib.bazel.coverage.CoverageReportActionBuilder.createCoverageActionsWrapper(CoverageReportActionBuilder.java:192)
at com.google.devtools.build.lib.bazel.coverage.BazelCoverageReportModule$1.createCoverageReportActionsWrapper(BazelCoverageReportModule.java:93)
at com.google.devtools.build.lib.analysis.BuildView.createResult(BuildView.java:436)
It appears that the default value of --coverage_report_generator causes this. Running it with --coverage_report_generator="@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main" works; though it should be pointed out that there are some SEVERE logs.
> bazel coverage --combined_report=lcov --coverage_report_generator="@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main" //...
INFO: Using default value for --instrumentation_filter: "//src/main/java/com/chris[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analysed 5 targets (23 packages loaded).
INFO: Found 3 targets and 2 test targets...
INFO: LCOV coverage report is located at /home/chris.rice/.cache/bazel/_bazel_chris.rice/1baebf64cb080dc7a8e39a79a89b8741/execroot/__main__/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From CoverageReport _coverage/_coverage_report.dat:
Oct 19, 2018 8:57:48 AM com.google.devtools.lcovmerger.Main getTracefiles
INFO: Found 2 tracefiles.
Oct 19, 2018 8:57:48 AM com.google.devtools.lcovmerger.Main parseFiles
SEVERE: Parsing file bazel-out/k8-fastbuild/testlogs/src/test/java/com/chris/foo/FooTest/coverage.dat
Oct 19, 2018 8:57:48 AM com.google.devtools.lcovmerger.Main parseFiles
SEVERE: Parsing file bazel-out/k8-fastbuild/testlogs/src/test/java/com/chris/hello/HelloWorldTest/coverage.dat
Oct 19, 2018 8:57:48 AM com.google.devtools.lcovmerger.Main getGcovInfoFiles
SEVERE: No gcov info file found.
INFO: Elapsed time: 6.037s, Critical Path: 5.47s
INFO: 15 processes: 10 linux-sandbox, 5 worker.
INFO: Build completed successfully, 35 total actions
//src/test/java/com/chris/foo:FooTest PASSED in 0.7s
/home/chris.rice/.cache/bazel/_bazel_chris.rice/1baebf64cb080dc7a8e39a79a89b8741/execroot/__main__/bazel-out/k8-fastbuild/testlogs/src/test/java/com/chris/foo/FooTest/coverage.dat
//src/test/java/com/chris/hello:HelloWorldTest PASSED in 0.6s
/home/chris.rice/.cache/bazel/_bazel_chris.rice/1baebf64cb080dc7a8e39a79a89b8741/execroot/__main__/bazel-out/k8-fastbuild/testlogs/src/test/java/com/chris/hello/HelloWorldTest/coverage.dat
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Clone this repo: https://github.com/chris-rice-lr/bazel_combined_report_repro and run
bazel coverage --combined_report=lcov //...
Running
bazel coverage --combined_report=lcov --coverage_report_generator="@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main" //...
will result in a single .dat file as expected
What operating system are you running Bazel on?
Fedora 28
What's the output of bazel info release?
> bazel info release
Starting local Bazel server and connecting to it...
release 0.18.0- (@non-git)
If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.
I used the COPR repo: https://copr.fedorainfracloud.org/coprs/vbatts/bazel/
What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?
> git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
[email protected]:chris-rice-lr/bazel_combined_report_repro.git
3b2b00c761c46fe8ea6a86deed47c8f10607ded3
3b2b00c761c46fe8ea6a86deed47c8f10607ded3
Have you found anything relevant by searching the web?
This thread helped. It showed that running with --coverage_report_generator set correctly made it work. https://groups.google.com/forum/#!searchin/bazel-discuss/combined_report%7Csort:date/bazel-discuss/itJkJ2T4mWw/qNKGEk_uFAAJ
Activity
fahhem commentedon Nov 7, 2018
I get this as well, almost filed another bug because this isn't marked as a bug.
My traceback is the same. Here's my bug details:
What operating system are you running Bazel on?
Ubuntu 16.04.4 LTS (inside a docker, inside Ubuntu 16.04.5 LTS)
What's the output of
bazel info release?release 0.19.0Other info
We've been using bazel inside this docker (with updates along the way) mostly-happily for a year now, so the docker stuff isn't the cause.
fahhem commentedon Nov 7, 2018
I get this traceback after setting the right flag:
--coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main"lukaszrek commentedon Jan 8, 2019
I have the same problem as @fahhem getting exception
I am running command:
I don't get this exception when running coverage on Ubuntu 18.04.1 LTS
It occurs on CentOS Linux release 7.5.1804 (Core)
Ls returns same on both Ubuntu and CentOS:
Using bazel 0.20.0
Please let me know if I can provide more debug information.
brendandouglas commentedon Jan 9, 2019
Is this actually specific to java rules -- perhaps the 'team-Rules-Java' tag should be removed?
'bazel coverage' with the '--combined_report=lcov' appears to be broken.
Still happening in bazel 0.21. Something that might be relevant: if I use
--coverage_report_generator=@bazel_tools//tools/test:coverage_report_generatorit fails with the original NPE, but specifying--coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Mainfails later, when trying to combine output .dat files.However
@bazel_tools//tools/test:coverage_report_generatoris just:ensonic commentedon Feb 27, 2019
I can second that this does not seem to be related to java. I get this for all kind of languages, eg:
sgammon commentedon Jul 21, 2019
is it true that, to this day, Java coverage doesn't work in Bazel? or am i missing some fix/change?
this bug has been open since 2018. is there anything the community can do to help move it along?
EDIT: or is it just
lcovoutput?iirina commentedon Jul 25, 2019
It works, you just have to specify another flag on the command line when using
--combined_report=lcov:The default value of the
--coverage_report_generatorflag is broken and we didn't get to fixing it. It should be an easy change though, PRs are always welcome. :)Note: this issue is about getting a combined report with coverage data from all test runs. If
--combined_reportis not specified Bazel creates a coverage report for each test run and the user has to merge them themselves or work with the reports as they are.bogatuadrian commentedon Jul 31, 2019
@iirina
LcovMergerseems to be missing from https://github.com/bazelbuild/bazel/tree/master/tools/test. Am I looking in the wrong place? If so, where should I findtools/test/LcovMerger/java/com/google/devtools/lcovmerger? Thanks.EDIT: OK, I found it at the
0.18.1tag, but I see that in newer versions of Bazel this has been renamed toCoverageOutputGenerator(8f4786b). I am using0.28.1. I will leave this here if other people run into this.codesuki commentedon Aug 5, 2019
@iirina
Trying to generate the coverage report for a go project with this cmdline
results in a runtime exception:
Any idea?
Bazel version:
Build label: 0.28.1-homebrew19 remaining items
ulfjack commentedon Feb 17, 2020
See my reply on #5426, which - I think - is the right bug.
greenwind89 commentedon Jul 22, 2020
Just for anyone who stumbles across this issue like I do, I am using an old Bazel version: 0.24.0. There is a change in Bazel 0.19.0, you need to change into --coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main to make it work.
Release note here https://blog.bazel.build/2018/10/29/bazel-0.19.0.html
lberki commentedon Nov 16, 2022
This still happens at HEAD:
bazel coverage --combined_report=lcov --coverage_report_generator=<an sh_library rule> <a cc_test rule>crashes with the following stack trace:
I'm fairly certain that this is due to a missing
FilesToRunProviderbecause binary rules in--coverage_report_generatordo work.cc @c-mita
c-mita commentedon Nov 16, 2022
That looks like the most likely reason for an NPE (
getExecutablereturns null). We can add a check here to avoid the crash, but the input tool definitely need to be executable.lberki commentedon Nov 16, 2022
Yeah, that's all I'm asking for; one can't do much with a tool that's not executable, it's just that crashing is not acceptable.