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

bazel coverage fails when a java_test references no source files #4309

Closed
kevingessner opened this issue Dec 15, 2017 · 4 comments
Closed

bazel coverage fails when a java_test references no source files #4309

kevingessner opened this issue Dec 15, 2017 · 4 comments
Assignees
Labels
coverage P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug

Comments

@kevingessner
Copy link
Contributor

Description of the problem / feature request / question:

If a java_test target does not reference any non-test source files (i.e. it only tests libraries), then bazel coverage generates an empty coverage.dat file. The LcovMerger fails with SEVERE: No lcov file found., even though an empty coverage file is valid in this case---there are no referenced files to be covered. LcovMerger should not fail in this case.

If possible, provide a minimal example to reproduce the problem:

https://github.com/kevingessner/bazel-lcov-repro

Environment info

  • Operating System: Linux (Centos 7)

  • Bazel version (output of bazel info release): Reproducible on 0.7.0 and 0.8.1

Have you found anything relevant by searching the web?

This error message is mentioned in #2528, but that issue is for a different coverage problem.

@kevingessner
Copy link
Contributor Author

Update: it appears that an empty coverage file is not in fact valid, per the lcov tool. So I think this bug is not in LcovMerger (which can reasonably abort on an empty file) but earlier in the coverage tooling -- if a test does not cover any files, no coverage.dat file should be generated for it at all.

@dclements
Copy link

dclements commented Jan 23, 2018

Having this problem as well and spent entirely too long tracking down why it was happening. It also happens if your test cases don't reference the main source code (local testing).

As an additional quirk in this, it reports a test failure when this happens:

INFO: Elapsed time: 1.195s, Critical Path: 0.98s
INFO: Build completed, 1 test FAILED, 9 total actions
//testpath                             FAILED in 0.7s
  /private/var/tmp/_bazel_<dir>/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/src/test/java/com/apigee/aisrv/admin/tests/test.log

Executed 1 out of 1 test: 1 fails locally.

@saurabhaditya
Copy link

I am also hitting into this issue. Is there any workaround to generate coverage?

SEVERE: No lcov file found.

Executed 1 out of 1 test: 1 fails locally.```

@saurabhaditya
Copy link

The above issue reported by me is likely unrelated, and happened when the path specified by instrumentation_filter value did not have any files, due to an unrelated issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug
Projects
None yet
Development

No branches or pull requests

5 participants