Skip to content

Commit ef54ef5

Browse files
c-mitacopybara-github
authored andcommitted
Expose metadata_files parameter in coverage_common.instrumented_files_info
Allows all rules to provide additional metadata files to the InstrumentedFilesInfo provider. It was always a little odd that the metadata_files attribute on the provider was exposed, but there was no way of populating it from Starlark. The other parameters are still considered too tied up with internal details at the moment to be exposed at this time. RELNOTES: coverage_common.instrumented_files_info now has a metadata_files argument PiperOrigin-RevId: 545391150 Change-Id: I3febdaf23c82d60c32b241a3935da27fd086fb7a
1 parent 92d6f22 commit ef54ef5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/java/com/google/devtools/build/lib/analysis/test/CoverageCommon.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ public InstrumentedFilesInfoApi instrumentedFilesInfo(
100100
// Should have been verified by Starlark before this function is called
101101
throw new IllegalStateException();
102102
}
103-
if (!supportFilesBuilder.isEmpty() || !environmentPairs.isEmpty()) {
104-
BuiltinRestriction.throwIfNotBuiltinUsage(thread);
105-
}
106-
if (!metadataFiles.isEmpty() || !reportedToActualSources.isEmpty()) {
103+
if (!supportFilesBuilder.isEmpty()
104+
|| !reportedToActualSources.isEmpty()
105+
|| !environmentPairs.isEmpty()) {
107106
BuiltinRestriction.throwIfNotBuiltinUsage(thread);
108107
}
109108
return createInstrumentedFilesInfo(

src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/CoverageCommonApi.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ public interface CoverageCommonApi<
9999
defaultValue = "None"),
100100
@Param(
101101
name = "metadata_files",
102+
doc =
103+
"Additional files required to generate coverage LCOV files after code execution."
104+
+ " e.g. .gcno files for C++.",
102105
named = true,
103106
positional = false,
104-
documented = false,
105107
defaultValue = "[]",
106108
allowedTypes = {
107109
@ParamType(type = Sequence.class, generic1 = FileApi.class),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,8 @@ public void testInstrumentedFilesInfo_coverageEnabled() throws Exception {
948948
"load('//myinfo:myinfo.bzl', 'MyInfo')",
949949
"",
950950
"def custom_rule_impl(ctx):",
951+
" metadata = ctx.actions.declare_file(ctx.label.name + '.metadata')",
952+
" ctx.actions.write(metadata, '')",
951953
" return [",
952954
" coverage_common.instrumented_files_info(",
953955
" ctx,",
@@ -967,6 +969,7 @@ public void testInstrumentedFilesInfo_coverageEnabled() throws Exception {
967969
// Missing attrs are ignored
968970
" 'missing_dep_attr',",
969971
" ],",
972+
" metadata_files = [metadata],",
970973
" ),",
971974
" ]",
972975
"",
@@ -1033,7 +1036,7 @@ public void testInstrumentedFilesInfo_coverageEnabled() throws Exception {
10331036
assertThat(
10341037
ActionsTestUtil.baseArtifactNames(
10351038
((Depset) myInfo.getValue("metadata_files")).getSet(Artifact.class)))
1036-
.containsExactly("label_dep.gcno", "label_list_dep.gcno", "dict_dep.gcno");
1039+
.containsExactly("label_dep.gcno", "label_list_dep.gcno", "dict_dep.gcno", "cr.metadata");
10371040
ConfiguredTarget customRule = getConfiguredTarget("//test/starlark:cr");
10381041
assertThat(
10391042
ActionsTestUtil.baseArtifactNames(

0 commit comments

Comments
 (0)