use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testStringListDictAttr.
@Test
public void testStringListDictAttr() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string_list_dict(default = {'a': ['b', 'c']})");
assertEquals(Type.STRING_LIST_DICT, attr.getType());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleLabelDefaultValue.
@Test
public void testRuleLabelDefaultValue() throws Exception {
evalAndExport("def impl(ctx): return None\n" + "r1 = rule(impl, attrs = {'a1': " + "attr.label(default = Label('//foo:foo'), allow_files=True)})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
Attribute a = c.getAttributeByName("a1");
assertThat(a.getDefaultValueForTesting()).isInstanceOf(Label.class);
assertEquals("//foo:foo", a.getDefaultValueForTesting().toString());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrWithOnlyType.
@Test
public void testAttrWithOnlyType() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string_list()");
assertEquals(Type.STRING_LIST, attr.getType());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrAllowEmpty.
@Test
public void testAttrAllowEmpty() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string_list(allow_empty=False)");
assertTrue(attr.isNonEmpty());
assertFalse(attr.isMandatory());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrCfgTarget.
@Test
public void testAttrCfgTarget() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label(cfg = 'target', allow_files = True)");
assertEquals(ConfigurationTransition.NONE, attr.getConfigurationTransition());
}
Aggregations