use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrWithProviders.
@Test
public void testAttrWithProviders() throws Exception {
Attribute attr = buildAttribute("a1", "b = provider()", "attr.label_list(allow_files = True, providers = ['a', b])");
assertThat(attr.getMandatoryProvidersList()).containsExactly(ImmutableSet.of(legacy("a"), declared("b")));
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testStringDictAttr.
@Test
public void testStringDictAttr() throws Exception {
Attribute attr = buildAttribute("a1", "attr.string_dict(default = {'a': 'b'})");
assertEquals(Type.STRING_DICT, attr.getType());
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAspectExtraDeps.
@Test
public void testAspectExtraDeps() throws Exception {
evalAndExport("def _impl(target, ctx):", " pass", "my_aspect = aspect(_impl,", " attrs = { '_extra_deps' : attr.label(default = Label('//foo/bar:baz')) }", ")");
SkylarkAspect aspect = (SkylarkAspect) ev.lookup("my_aspect");
Attribute attribute = Iterables.getOnlyElement(aspect.getAttributes());
assertThat(attribute.getName()).isEqualTo("$extra_deps");
assertThat(attribute.getDefaultValue(null)).isEqualTo(Label.parseAbsolute("//foo/bar:baz", false));
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrWithProvidersList.
@Test
public void testAttrWithProvidersList() throws Exception {
Attribute attr = buildAttribute("a1", "b = provider()", "attr.label_list(allow_files = True, providers = [['a', b], ['c']])");
assertThat(attr.getMandatoryProvidersList()).containsExactly(ImmutableSet.of(legacy("a"), declared("b")), ImmutableSet.of(legacy("c")));
}
use of com.google.devtools.build.lib.packages.Attribute in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testAttrIntValues.
@Test
public void testAttrIntValues() throws Exception {
Attribute attr = buildAttribute("a1", "attr.int(values = [1, 2])");
PredicateWithMessage<Object> predicate = attr.getAllowedValues();
assertThat(predicate.apply(2)).isTrue();
assertThat(predicate.apply(3)).isFalse();
}
Aggregations