Bazel produces an over-aggressive instrumentation_filter #11962
Labels
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-Rules-Server
Issues for serverside rules included with Bazel
type: bug
Description of the problem / feature request:
If one of the targets passed to
bazel coverage
is one level below the root of the repo (e.g.,//foo
inbazel coverage //foo:go_default_test //bar/baz:go_default_test
), Bazel would infer the--instrumentation_filter
to be//
. This is undesirable, because it will instrument the test coverage for the whole transitive dependency of both//foo:go_default_test
and//bar:go_default_test
, including third-party libraries.When we run
bazel coverage //foo:go_default_test //bar/baz:go_default_test
, we are only interested in the test coverage of those two packages, so only those two packages need to be instrumented. When we runbazel test //foo:go_default_test //bar/baz:go_default_test
and thenbazel coverage //foo:go_default_test //bar/baz:go_default_test
, we would expect only//foo:go_default_test
and//bar/baz:go_default_test
are rebuilt because of the extra instrumentation code. Their dependencies should not need rebuild. Due to the over-instrumentation, the whole transitive graph is rebuilt.Even for targets deep below, the behavior is not desirable either. For example,
bazel coverage //foo/bar:go_default_test //foo/baz:go_default_test
would have--instrumentation_filter=//foo[:/]
by default. As a result all transitive dependencies under//foo/
will have to rebuild betweenbazel coverage
andbazel test
, even when only//foo/bar
and//foo/baz
need to be instrumented for test coverage.I think Bazel should either turn off such optimization entirely, or only optimize for certain wildcard patterns such as
//foo/...
, suchbazel test
andbazel coverage
can share cache except the tested targets.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
bazel coverage --announce_rc //foo:go_default_test //bar/baz:go_default_test
What operating system are you running Bazel on?
macOS
What's the output of
bazel info release
?release 3.4.1-homebrew
Have you found anything relevant by searching the web?
optimizeFilterSet transformed
packageFilters
from{"foo", "bar/baz"}
to{""}
, which becomes//[/:]
later. Then this line further transformed it into//
.The text was updated successfully, but these errors were encountered: