Search in sources :

Example 1 with LateBoundLabel

use of com.google.devtools.build.lib.packages.Attribute.LateBoundLabel in project bazel by bazelbuild.

the class AspectDefinitionTest method testAspectWithImplicitOrLateboundAttribute_AddsToAttributeMap.

@Test
public void testAspectWithImplicitOrLateboundAttribute_AddsToAttributeMap() throws Exception {
    Attribute implicit = attr("$runtime", BuildType.LABEL).value(Label.parseAbsoluteUnchecked("//run:time")).build();
    LateBoundLabel<String> latebound = new LateBoundLabel<String>() {

        @Override
        public Label resolve(Rule rule, AttributeMap attributes, String configuration) {
            return Label.parseAbsoluteUnchecked("//run:away");
        }
    };
    AspectDefinition simple = new AspectDefinition.Builder(TEST_ASPECT_CLASS).add(implicit).add(attr(":latebound", BuildType.LABEL).value(latebound)).build();
    assertThat(simple.getAttributes()).containsEntry("$runtime", implicit);
    assertThat(simple.getAttributes()).containsKey(":latebound");
    assertThat(simple.getAttributes().get(":latebound").getLateBoundDefault()).isEqualTo(latebound);
}
Also used : AttributeMap(com.google.devtools.build.lib.packages.AttributeMap) Attribute(com.google.devtools.build.lib.packages.Attribute) LateBoundLabel(com.google.devtools.build.lib.packages.Attribute.LateBoundLabel) AspectDefinition(com.google.devtools.build.lib.packages.AspectDefinition) Rule(com.google.devtools.build.lib.packages.Rule) Test(org.junit.Test)

Aggregations

AspectDefinition (com.google.devtools.build.lib.packages.AspectDefinition)1 Attribute (com.google.devtools.build.lib.packages.Attribute)1 LateBoundLabel (com.google.devtools.build.lib.packages.Attribute.LateBoundLabel)1 AttributeMap (com.google.devtools.build.lib.packages.AttributeMap)1 Rule (com.google.devtools.build.lib.packages.Rule)1 Test (org.junit.Test)1