Skip to content

Commit 5b216b2

Browse files
Googlercopybara-github
authored andcommitted
Flip default for experimental_forward_instrumented_files_info_by_default
This changes the default behavior for coverage from "forward nothing" to "forward InstrumentedFilesInfo from non-tool dependencies". This is still not quite ideal behavior, since typically attributes which provide source files (like srcs) are non-tool dependencies. But it's an improvement because it avoids the need for explicit coverage configuration for the entire chain of dependencies from test to source file. In cases where an aspect returned InstrumentedFilesInfo previously, the InstrumentedFilesInfo provider for the base rule is ignored, so the behavior will be unchanged. The bit about coverage_common.instrumented_files_info is merged into the related section under "Advanced Topics" in the rules documentation, since it's no longer required for the whole dependency chain to configure coverage explicitly in order for that to work at all. RELNOTES: Forward coverage-instrumented files from non-tool dependencies by default. PiperOrigin-RevId: 380224680
1 parent d09077e commit 5b216b2

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public String getTypeDescription() {
380380

381381
@Option(
382382
name = "experimental_forward_instrumented_files_info_by_default",
383-
defaultValue = "false",
383+
defaultValue = "true",
384384
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
385385
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
386386
help =

src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,18 +1117,16 @@ public void instrumentedFilesInfoFromBaseRuleAndAspectUsesAspect() throws Except
11171117
.containsExactly("a");
11181118
assertThat(getInstrumentedFiles("//aspect:instrumented_file_info_from_base_target"))
11191119
.containsExactly("b");
1120-
assertThat(getInstrumentedFilesInfo("//aspect:rule_target_no_coverage")).isNull();
1120+
assertThat(getInstrumentedFiles("//aspect:rule_target_no_coverage")).isEmpty();
11211121
assertThat(getInstrumentedFiles("//aspect:instrumented_files_info_only_from_aspect"))
11221122
.containsExactly("a");
11231123
assertThat(getInstrumentedFiles("//aspect:no_instrumented_files_info")).isEmpty();
11241124
}
11251125

11261126
private List<String> getInstrumentedFiles(String label) throws InterruptedException {
11271127
return ActionsTestUtil.baseArtifactNames(
1128-
getInstrumentedFilesInfo(label).getInstrumentedFiles());
1129-
}
1130-
1131-
private InstrumentedFilesInfo getInstrumentedFilesInfo(String label) throws InterruptedException {
1132-
return getConfiguredTarget(label).get(InstrumentedFilesInfo.STARLARK_CONSTRUCTOR);
1128+
getConfiguredTarget(label)
1129+
.get(InstrumentedFilesInfo.STARLARK_CONSTRUCTOR)
1130+
.getInstrumentedFiles());
11331131
}
11341132
}

src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,10 @@ public void testInstrumentedFilesForwardedFromDepsByDefaultExperimentFlag() thro
941941
// Current behavior is that nothing gets forwarded if IntstrumentedFilesInfo is not configured.
942942
// That means that source files are not collected for the coverage manifest unless the entire
943943
// dependency chain between the test and the source file explicitly configures coverage.
944-
// New behavior is protected by --experimental_forward_instrumented_files_info_by_default.
945-
useConfiguration("--collect_code_coverage");
944+
// New behavior is controlled by --experimental_forward_instrumented_files_info_by_default,
945+
// which is now on by default.
946+
useConfiguration(
947+
"--collect_code_coverage", "--noexperimental_forward_instrumented_files_info_by_default");
946948
ConfiguredTarget target = getConfiguredTarget("//test/starlark:outer");
947949
InstrumentedFilesInfo provider = target.get(InstrumentedFilesInfo.STARLARK_CONSTRUCTOR);
948950
assertWithMessage("InstrumentedFilesInfo should be set.").that(provider).isNotNull();
@@ -952,8 +954,7 @@ public void testInstrumentedFilesForwardedFromDepsByDefaultExperimentFlag() thro
952954
// dependencies. Coverage still needs to be configured for rules that handle source files for
953955
// languages which support coverage instrumentation, but not every wrapper rule in the
954956
// dependency chain needs to configure that for instrumentation to be correct.
955-
useConfiguration(
956-
"--collect_code_coverage", "--experimental_forward_instrumented_files_info_by_default");
957+
useConfiguration("--collect_code_coverage");
957958
target = getConfiguredTarget("//test/starlark:outer");
958959
provider = target.get(InstrumentedFilesInfo.STARLARK_CONSTRUCTOR);
959960
assertWithMessage("InstrumentedFilesInfo should be set.").that(provider).isNotNull();

0 commit comments

Comments
 (0)