use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrCfg.
@Test
public void testAttrCfg() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label(cfg = 'host', allow_files = True)");
assertEquals(ConfigurationTransition.HOST, attr.getConfigurationTransition());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrNonEmpty.
@Test
public void testAttrNonEmpty() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string_list(non_empty=True)");
assertTrue(attr.isNonEmpty());
assertFalse(attr.isMandatory());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAspectParameter.
@Test
public void testAspectParameter() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "my_aspect = aspect(_impl,", " attrs = { 'param' : attr.string(values=['a', 'b']) }", ")");
SkylarkAspect aspect = (SkylarkAspect) ev.lookup("my_aspect");
Attribute attribute = Iterables.getOnlyElement(aspect.getAttributes());
assertThat(attribute.getName()).isEqualTo("param");
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrWithList.
@Test
public void testAttrWithList() throws Exception {
Attribute attr = buildAttribute("a1", "attr.label_list(allow_files = ['.xml'])");
assertTrue(attr.getAllowedFileTypesPredicate().apply("a.xml"));
assertFalse(attr.getAllowedFileTypesPredicate().apply("a.txt"));
assertFalse(attr.isSingleArtifact());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class DependencyResolverTest method hasAspectsRequiredByAspect.
@Test
public void hasAspectsRequiredByAspect() throws Exception {
setRulesAvailableInTests(new TestAspects.BaseRule(), new TestAspects.SimpleRule());
pkg("a", "simple(name='a', foo=[':b'])", "simple(name='b', foo=[])");
OrderedSetMultimap<Attribute, Dependency> map = dependentNodeMap("//a:a", TestAspects.ATTRIBUTE_ASPECT);
assertDep(map, "foo", "//a:b", new AspectDescriptor(TestAspects.ATTRIBUTE_ASPECT));
}
Aggregations