Add ctx.coverage_instrumented function to Skylark
Add ctx.coverage_instrumented function to Skylark

Skylark already has ctx.configuration.coverage_enabled to determine if coverage data collection is on for an entire run. But that does not reveal which targets specifically are supposed to be instrumented (based on the values of --instrumentation_filer and --instrument_test_targets). This is inefficient for languages which add coverage instrumentation at compile-time, though correct coverage output can still be produced by instrumenting everything and filtering later.

By default, this function returns whether the rule represented by ctx should be instrumented. If a Skylark Target (e.g. from a label or label_list attribute in ctx.attr) is passed to the function, it instead returns whether that Target is a rule whose sources should be instrumented. Rules that directly incorporate source-files from their dependencies before compilation (e.g. header files) may need to know if those source files need to be instrumented when compiled.

Expanded the documentation of instrumented_files to be a more general section on implementing code coverage instrumentation in Skylark.

Also tweaked the code comment and variable names for the version of shouldIncludeLocalSources that takes a TransitiveInfoCollection.

RELNOTES: Add ctx.coverage_instrumented function to Skylark, to indicate whether a specific targets should be instrumented for code coverage data collection.

--
MOS_MIGRATED_REVID=139460989

davidzchen/bazel-website,bazelbuild/bazel-website,davidzchen/bazel-website,bazelbuild/bazel-website,davidzchen/bazel-website,bazelbuild/bazel-website,davidzchen/bazel-website