Search in sources :

Example 71 with Attribute

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());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) Test(org.junit.Test)

Example 72 with Attribute

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());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) RuleFunction(com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction) RuleClass(com.google.devtools.build.lib.packages.RuleClass) Test(org.junit.Test)

Example 73 with Attribute

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());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) Test(org.junit.Test)

Example 74 with Attribute

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());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) Test(org.junit.Test)

Example 75 with Attribute

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());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) Test(org.junit.Test)

Aggregations

Attribute (com.google.devtools.build.lib.packages.Attribute)76 Test (org.junit.Test)37 Label (com.google.devtools.build.lib.cmdline.Label)20 Rule (com.google.devtools.build.lib.packages.Rule)20 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)7 AttributeMap (com.google.devtools.build.lib.packages.AttributeMap)7 Target (com.google.devtools.build.lib.packages.Target)7 ArrayList (java.util.ArrayList)7 LinkedHashMap (java.util.LinkedHashMap)7 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)6 ConfigMatchingProvider (com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider)6 RuleClass (com.google.devtools.build.lib.packages.RuleClass)6 SkyKey (com.google.devtools.build.skyframe.SkyKey)6 LinkedHashSet (java.util.LinkedHashSet)6 Nullable (javax.annotation.Nullable)6 AspectDescriptor (com.google.devtools.build.lib.packages.AspectDescriptor)5 Map (java.util.Map)5 Dependency (com.google.devtools.build.lib.analysis.Dependency)4