4

I'm trying to generate Python coverage in bazel. I tried to run this command and an empty file was generated

$ bazelisk coverage //company/libs:foo_test
INFO: Using default value for --instrumentation_filter: "^//company/libs[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed target //company/libs:foo_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //company/libs:foo_test up-to-date:
  bazel-bin/company/libs/foo_test
INFO: Elapsed time: 0.244s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
//company/libs:foo_test                                        (cached) PASSED in 0.8s

$ cat bazel-out/k8-fastbuild/testlogs/company/libs/foo_test/coverage.dat
$ cat bazel-out/k8-fastbuild/testlogs/company/libs/foo_test/baseline_coverage.dat

How do I run coverage, and generate data points for the files?

Ahmed
  • 2,825
  • 1
  • 25
  • 39
  • 1
    It's not trivial at the moment. Take a look at https://github.com/bazelbuild/bazel/issues/10660 for inspiration on how to build a workaround. – Laurenz May 08 '21 at 11:28

1 Answers1

-1

bazel coverage --combined_report=lcov [target]

Japheth
  • 7
  • 3
  • 3
    Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Jan 15 '23 at 12:50
  • 1
    Using Bazel 6.0.0 and macOS this gives me 'WARNUNG: There was no coverage found.'. The LCOV generated coverage report seems also to be empty – Vertexwahn Jan 23 '23 at 11:23