use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class AggregatingAttributeMapperTest method testDuplicateCheckOnNullValues.
@Test
public void testDuplicateCheckOnNullValues() throws Exception {
if (getAnalysisMock().isThisBazel()) {
return;
}
Rule rule = scratchRule("x", "main", "java_binary(", " name = 'main',", " srcs = ['main.java'])");
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
Attribute launcherAttribute = mapper.getAttributeDefinition("launcher");
assertNull(mapper.get(launcherAttribute.getName(), launcherAttribute.getType()));
assertThat(mapper.checkForDuplicateLabels(launcherAttribute)).containsExactlyElementsIn(ImmutableList.of());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class RuleDocumentationAttributeTest method testSynopsisForLabelListAttribute.
@Test
public void testSynopsisForLabelListAttribute() {
Attribute attribute = Attribute.attr("some_labels", BuildType.LABEL_LIST).allowedRuleClasses("foo_rule").allowedFileTypes().build();
RuleDocumentationAttribute attributeDoc = RuleDocumentationAttribute.create(TestRule.class, "testrule", "", 0, "", NO_FLAGS);
attributeDoc.setAttribute(attribute);
String doc = attributeDoc.getSynopsis();
assertEquals("List of <a href=\"../build-ref.html#labels\">labels</a>; optional", doc);
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class RuleDocumentationAttributeTest method testSynopsisForStringAttribute.
@Test
public void testSynopsisForStringAttribute() {
final String defaultValue = "9";
Attribute attribute = Attribute.attr("foo_version", Type.STRING).value(defaultValue).build();
RuleDocumentationAttribute attributeDoc = RuleDocumentationAttribute.create(TestRule.class, "testrule", "", 0, "", NO_FLAGS);
attributeDoc.setAttribute(attribute);
String doc = attributeDoc.getSynopsis();
assertEquals("String; optional; default is \"" + defaultValue + "\"", doc);
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class RuleDocumentationAttributeTest method testSynopsisForMandatoryAttribute.
@Test
public void testSynopsisForMandatoryAttribute() {
Attribute attribute = Attribute.attr("baz_labels", BuildType.LABEL).mandatory().allowedFileTypes(CppFileTypes.CPP_HEADER).build();
RuleDocumentationAttribute attributeDoc = RuleDocumentationAttribute.create(TestRule.class, "testrule", "", 0, "", NO_FLAGS);
attributeDoc.setAttribute(attribute);
String doc = attributeDoc.getSynopsis();
assertEquals("<a href=\"../build-ref.html#labels\">Label</a>; required", doc);
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class AspectAwareAttributeMapperTest method createMapper.
@Before
public final void createMapper() throws Exception {
RuleConfiguredTarget ct = (RuleConfiguredTarget) scratchConfiguredTarget("foo", "myrule", "cc_binary(", " name = 'myrule',", " srcs = [':a.cc'],", " linkstatic = select({'//conditions:default': 1}))");
rule = ct.getTarget();
Attribute aspectAttr = new Attribute.Builder<Label>("fromaspect", BuildType.LABEL).allowedFileTypes(FileTypeSet.ANY_FILE).build();
aspectAttributes = ImmutableMap.<String, Attribute>of(aspectAttr.getName(), aspectAttr);
mapper = new AspectAwareAttributeMapper(ConfiguredAttributeMapper.of(ct), aspectAttributes);
}
Aggregations