Clarification on Bazel Coverage Behaviour

43 views
Skip to first unread message

Roshan Kumar

unread,
Mar 5, 2025, 4:43:53 PMMar 5
to bazel-discuss


Hello Bazel Community,

I have been testing coverage collection with Bazel and wanted to share my findings in response to a point noted in the Bazel documentation on coverage.

Documentation Claim:

The documentation mentions:

"Bazel will currently fail to create coverage information if tests have been cached previously. To work around this, --nocache_test_results can be set specifically for coverage runs, although this of course incurs a heavy cost in terms of test times."

My Observations:

In my experiments, I ran bazel coverage with and without caching enabled and consistently received correct results. Specifically, when I made changes to the tests, Bazel correctly re-ran those tests and utilized the build cache effectively. It worked flawlessly, even with cached test results.

Confusion About Documentation:

Given my successful results, I am puzzled by the documentation's assertion that Bazel fails to generate coverage information with cached test results. My experience suggests that it functions as expected without needing to disable cache specifically for coverage runs.

Environment Details:
Bazel version: 7.1.0
Command used:
bazel coverage --keep_going --build_tests_only <other_flags> --@io_bazel_rules_go//go/config:cover_format=go_cover -- <targets>

Question to the Community:

Has anyone else encountered a similar discrepancy between the documentation and actual behavior? If there are specific scenarios where this issue manifests, I would appreciate any insights. Otherwise, it might be worth revisiting the documentation to reflect its correct functionality.

Looking forward to your thoughts and experiences!

Fabian Meumertzheim

unread,
Mar 5, 2025, 5:05:31 PMMar 5
to Roshan Kumar, bazel-discuss
The documentation is outdated and coverage is actually far more reliable now than it used to be. If you use a remote or disk cache, you may encounter issues if you don't flip certain flips, but I have a PR out to flip those by default: https://github.com/bazelbuild/bazel/pull/24927

--
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 visit https://groups.google.com/d/msgid/bazel-discuss/68928a4c-2057-4cc9-8651-5a2834ad79dcn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages