Skip to content

Commit a9530b0

Browse files
author
Tamas Vajk
committed
Set --instrumentation_filter for coverage in .bazelrc
Without an explicit --instrumentation_filter, Bazel's default filter may not match workspace targets, causing ctx.coverage_instrumented() to return False and producing empty Rust coverage reports. Add coverage --instrumentation_filter=^// to .bazelrc so that all workspace targets are instrumented by default. Projects with vendored dependencies should narrow this, e.g.: coverage --instrumentation_filter=^//,-^//third_party
1 parent 718558f commit a9530b0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.bazelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ coverage --combined_report=lcov
2020
coverage --experimental_fetch_all_coverage_outputs
2121
coverage --experimental_split_coverage_postprocessing
2222

23+
# Instrument all workspace targets for coverage. Without this, the default
24+
# --instrumentation_filter may not match workspace targets, resulting in
25+
# empty coverage reports. Projects should adjust this to exclude vendored
26+
# dependencies, e.g.: coverage --instrumentation_filter=^//,-^//third_party
27+
coverage --instrumentation_filter=^//
28+
2329
# Required for some of the tests
2430
# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library
2531
common --experimental_cc_shared_library

0 commit comments

Comments
 (0)