diff options
author | cparsons <cparsons@google.com> | 2018-02-16 14:21:10 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-16 14:23:13 -0800 |
commit | 7ec3f21cad07c4b6726bf1ee89e808298e4959c9 (patch) | |
tree | bde139bf283b75f4dd023ae4896be23faec7c20e /src/test/java/com | |
parent | 50efbeb1a59a17ef23dd125540492518860971ff (diff) |
Change Skylark's print() on a rule target to print the Skylark-exposed provider keys.
This change only affects printing a rule target directly -- it intentionally does not affect the behavior of str(target), as we want to avoid skylark code being able to parse potentially-private provider keys.
RELNOTES: In skylark, print(target) now shows the provider keys of a target, as debug information.
PiperOrigin-RevId: 186046226
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java index 6f8e3843b0..8764ac499e 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java @@ -916,6 +916,46 @@ public class SkylarkIntegrationTest extends BuildViewTestCase { } @Test + public void testPrintProviderCollection() throws Exception { + scratch.file( + "test/skylark/rules.bzl", + "", + "FooInfo = provider()", + "BarInfo = provider()", + "", + "def _top_level_rule_impl(ctx):", + " print('My Dep Providers:', ctx.attr.my_dep)", + "", + "def _dep_rule_impl(name):", + " providers = [", + " FooInfo(),", + " BarInfo(),", + " ]", + " return providers", + "", + "top_level_rule = rule(", + " implementation=_top_level_rule_impl,", + " attrs={'my_dep':attr.label()}", + ")", + "", + "dep_rule = rule(", + " implementation=_dep_rule_impl,", + ")"); + + scratch.file( + "test/skylark/BUILD", + "load('//test/skylark:rules.bzl', 'top_level_rule', 'dep_rule')", + "", + "top_level_rule(name = 'tl', my_dep=':d')", + "", + "dep_rule(name = 'd')"); + + getConfiguredTarget("//test/skylark:tl"); + assertContainsEvent( + "My Dep Providers: <target //test/skylark:d, keys:[FooInfo, BarInfo, OutputGroupInfo]>"); + } + + @Test public void testRuleClassImplicitOutputFunctionPrints() throws Exception { scratch.file( "test/skylark/extension.bzl", |