use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction 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.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleAddAttribute.
@Test
public void testRuleAddAttribute() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl, attrs={'a1': attr.string()})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
assertTrue(c.hasAttr("a1", Type.STRING));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction 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.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testOutputToGenfiles.
@Test
public void testOutputToGenfiles() throws Exception {
evalAndExport("def impl(ctx): pass", "r1 = rule(impl, output_to_genfiles=True)");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
assertFalse(c.hasBinaryOutput());
}
Aggregations