use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrAllowedRuleClassesSpecificRuleClasses.
@Test
public void testAttrAllowedRuleClassesSpecificRuleClasses() throws Exception {
Attribute attr = buildAttribute("a", "attr.label_list(allow_rules = ['java_binary'], allow_files = True)");
assertTrue(attr.getAllowedRuleClassesPredicate().apply(ruleClass("java_binary")));
assertFalse(attr.getAllowedRuleClassesPredicate().apply(ruleClass("genrule")));
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testIntListAttr.
@Test
public void testIntListAttr() throws Exception {
Attribute attr = buildAttribute("a1", "attr.int_list()");
assertEquals(Type.INTEGER_LIST, attr.getType());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrValues.
@Test
public void testAttrValues() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string(values = ['ab', 'cd'])");
PredicateWithMessage<Object> predicate = attr.getAllowedValues();
assertThat(predicate.apply("ab")).isTrue();
assertThat(predicate.apply("xy")).isFalse();
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testOutputListAttr.
@Test
public void testOutputListAttr() throws Exception {
Attribute attr = buildAttribute("a1", "attr.output_list()");
assertEquals(BuildType.OUTPUT_LIST, attr.getType());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrMandatory.
@Test
public void testAttrMandatory() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string(mandatory=True)");
assertTrue(attr.isMandatory());
assertFalse(attr.isNonEmpty());
}
Aggregations