diff --git a/src/test/java/com/google/devtools/build/lib/analysis/starlark/StarlarkSubruleTest.java b/src/test/java/com/google/devtools/build/lib/analysis/starlark/StarlarkSubruleTest.java index 20d9ac8a10dd93..1b8e2bb0d7c2f9 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/starlark/StarlarkSubruleTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/starlark/StarlarkSubruleTest.java @@ -150,6 +150,38 @@ public void testSubrule_aspectMustDeclareSubrule() throws Exception { + " declare '_my_subrule' in 'subrules'"); } + // this is a bug that must be fixed + @Test + public void testSubruleCallingSibling_succeeds() throws Exception { + scratch.file( + "subrule_testing/myrule.bzl", + "def _subrule1_impl(ctx):", + " return 'result from subrule1'", + "_my_subrule1 = subrule(implementation = _subrule1_impl)", + "", + "def _subrule2_impl(ctx):", + " return _my_subrule1()", + "_my_subrule2 = subrule(implementation = _subrule2_impl)", + "", + "MyInfo=provider()", + "def _rule_impl(ctx):", + " res = _my_subrule2()", + " return [MyInfo(result = res)]", + "", + "my_rule = rule(_rule_impl, subrules = [_my_subrule2, _my_subrule1])"); + scratch.file( + "subrule_testing/BUILD", + // + "load('myrule.bzl', 'my_rule')", + "my_rule(name = 'foo')"); + + StructImpl provider = + getProvider("//subrule_testing:foo", "//subrule_testing:myrule.bzl", "MyInfo"); + + assertThat(provider).isNotNull(); + assertThat(provider.getValue("result")).isEqualTo("result from subrule1"); + } + @Test public void testSubrule_implementationMustAcceptSubruleContext() throws Exception { scratch.file(