Added named=true to output_group.group_name This was migrated incorrectly, as there's a semantic difference between @Param for @SkylarkSignature and for @SkylarkCallable, it would appear. RELNOTES: None. PiperOrigin-RevId: 188190409
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TransitiveInfoCollection.java b/src/main/java/com/google/devtools/build/lib/analysis/TransitiveInfoCollection.java index e557cc2..0727e22 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/TransitiveInfoCollection.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/TransitiveInfoCollection.java
@@ -72,7 +72,7 @@ @SkylarkCallable(name = "output_group", documented = false, // TODO(dslomov): document. parameters = { - @Param(name = "group_name", type = String.class, doc = "Output group name") + @Param(name = "group_name", type = String.class, doc = "Output group name", named = true) } ) default SkylarkNestedSet outputGroup(String group) {
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java index 10acb87..998cf66 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkDefinedAspectsTest.java
@@ -403,6 +403,39 @@ } @Test + public void aspectWithOutputGroupsExplicitParamName() throws Exception { + scratch.file( + "test/aspect.bzl", + "def _impl(target, ctx):", + " f = target.output_group(group_name = '_hidden_top_level" + INTERNAL_SUFFIX + "')", + " return struct(output_groups = { 'my_result' : f })", + "", + "MyAspect = aspect(", + " implementation=_impl,", + ")"); + scratch.file( + "test/BUILD", + "java_library(", + " name = 'xxx',", + " srcs = ['A.java'],", + ")"); + + AnalysisResult analysisResult = + update(ImmutableList.of("test/aspect.bzl%MyAspect"), "//test:xxx"); + assertThat(getLabelsToBuild(analysisResult)).containsExactly("//test:xxx"); + AspectValue aspectValue = analysisResult.getAspects().iterator().next(); + OutputGroupInfo outputGroupInfo = OutputGroupInfo.get( + aspectValue.getConfiguredAspect()); + + assertThat(outputGroupInfo).isNotNull(); + NestedSet<Artifact> names = outputGroupInfo.getOutputGroup("my_result"); + assertThat(names).isNotEmpty(); + NestedSet<Artifact> expectedSet = OutputGroupInfo.get(getConfiguredTarget("//test:xxx")) + .getOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL); + assertThat(names).containsExactlyElementsIn(expectedSet); + } + + @Test public void aspectWithOutputGroupsDeclaredProvider() throws Exception { scratch.file( "test/aspect.bzl",