use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleAddMultipleAttributes.
@Test
public void testRuleAddMultipleAttributes() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl,", " attrs = {", " 'a1': attr.label_list(allow_files=True),", " 'a2': attr.int()", "})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
assertTrue(c.hasAttr("a1", BuildType.LABEL_LIST));
assertTrue(c.hasAttr("a2", Type.INTEGER));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleOutputs.
@Test
public void testRuleOutputs() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl, outputs = {'a': 'a.txt'})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
ImplicitOutputsFunction function = c.getDefaultImplicitOutputsFunction();
assertEquals("a.txt", Iterables.getOnlyElement(function.getImplicitOutputs(null)));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleImplementation.
@Test
public void testRuleImplementation() throws Exception {
evalAndExport("def impl(ctx): return None", "rule1 = rule(impl)");
RuleClass c = ((RuleFunction) lookup("rule1")).getRuleClass();
assertEquals("impl", c.getConfiguredTargetFunction().getName());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleAttributeFlag.
@Test
public void testRuleAttributeFlag() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl, attrs = {'a1': attr.string(mandatory=True)})");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
assertTrue(c.getAttributeByName("a1").isMandatory());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testRuleInheritsBaseRuleAttributes.
@Test
public void testRuleInheritsBaseRuleAttributes() throws Exception {
evalAndExport("def impl(ctx): return None", "r1 = rule(impl)");
RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
assertTrue(c.hasAttr("tags", Type.STRING_LIST));
assertTrue(c.hasAttr("visibility", BuildType.NODEP_LABEL_LIST));
assertTrue(c.hasAttr("deprecation", Type.STRING));
// required for extra actions
assertTrue(c.hasAttr(":action_listener", BuildType.LABEL_LIST));
}
Aggregations