Strange behavior of bazel c++ coverage

1,035 views
Skip to first unread message

Łukasz Tekieli

unread,
Sep 21, 2018, 9:10:56 AM9/21/18
to bazel-...@googlegroups.com
Hello,
please check the following repo: https://github.com/ltekieli/bazel_coverage
Basically, when the cc_test rule does not depend on a cc_library defined in the same workspace,
the coverage output is broken, looks like the gcda and gcno files are not available for the script that gathers coverage, altough when run outside of the sandbox, gcda files are there. Please confirm this is unexpected, we can report a bug then. Thanks.

--
Łukasz Tekieli

Irina Iancu

unread,
Sep 21, 2018, 10:09:31 AM9/21/18
to tekieli...@gmail.com, bazel-discuss
Hi Lukasz,

This is working as intended because by default bazel does not instrument sources of test targets. If you want to get coverage for your use case you have to enable --instrument_test_targets when running bazel coverage.
Try "bazel coverage --instrument_test_targets ..." and it should work.

Additionally you can get a combined coverage report for all your test runs in  bazel-out/_coverage/_coverage_report.dat by specifying the --combined_report and --coverage_report_generator flags:

bazel coverage --instrument_test_targets --coverage_report_generator=@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main --combined_report=lcov ...

Cheers,
Irina

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAFfxioxuXOONn%3Dw%3Du8i6%3Dm5gCvrAKjzHPFTuMwbay2-v2Yw%2B-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Łukasz Tekieli

unread,
Sep 21, 2018, 11:45:36 AM9/21/18
to elena...@google.com, bazel-...@googlegroups.com
Thanks a lot, that answers my question. I think i should read the help more carefully next time ;)
--
Łukasz Tekieli
Reply all
Reply to author
Forward
0 new messages