use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrSingleFileWithList.
@Test
public void testAttrSingleFileWithList() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label(allow_single_file = ['.xml'])");
assertTrue(attr.getAllowedFileTypesPredicate().apply("a.xml"));
assertFalse(attr.getAllowedFileTypesPredicate().apply("a.txt"));
assertTrue(attr.isSingleArtifact());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testIntDefaultValue.
@Test
public void testIntDefaultValue() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl, attrs = {'a1': attr.int(default = 40+2)})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
Attribute a = c.getAttributeByName("a1");
assertEquals(42, a.getDefaultValueForTesting());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrAllowedFileTypesAnyFile.
@Test
public void testAttrAllowedFileTypesAnyFile() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label_list(allow_files = True)");
assertEquals(FileTypeSet.ANY_FILE, attr.getAllowedFileTypesPredicate());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrCfgData.
@Test
public void testAttrCfgData() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label(cfg = 'data', allow_files = True)");
assertEquals(ConfigurationTransition.DATA, attr.getConfigurationTransition());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrDefaultValue.
@Test
public void testAttrDefaultValue() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string(default = 'some value')");
assertEquals("some value", attr.getDefaultValueForTesting());
}
Aggregations