Search in sources :

Example 1 with RuleConfiguredTarget

use of com.google.devtools.build.lib.analysis.RuleConfiguredTarget in project bazel by bazelbuild.

the class SkylarkIntegrationTest method testTransitiveInfoProviders.

@Test
public void testTransitiveInfoProviders() throws Exception {
    scratch.file("test/skylark/extension.bzl", "def custom_rule_impl(ctx):", "  attr1 = ctx.files.attr1", "  ftb = depset(attr1)", "  return struct(provider_key = ftb)", "", "custom_rule = rule(implementation = custom_rule_impl,", "  attrs = {'attr1': attr.label_list(mandatory=True, allow_files=True)})");
    scratch.file("test/skylark/BUILD", "load('/test/skylark/extension', 'custom_rule')", "", "custom_rule(name = 'cr', attr1 = [':a.txt'])");
    RuleConfiguredTarget target = (RuleConfiguredTarget) getConfiguredTarget("//test/skylark:cr");
    assertThat(ActionsTestUtil.baseArtifactNames(((SkylarkNestedSet) target.get("provider_key")).getSet(Artifact.class))).containsExactly("a.txt");
}
Also used : RuleConfiguredTarget(com.google.devtools.build.lib.analysis.RuleConfiguredTarget) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)1 RuleConfiguredTarget (com.google.devtools.build.lib.analysis.RuleConfiguredTarget)1 Test (org.junit.Test)1