Skylark: Test rules are implictly executable.
--
MOS_MIGRATED_REVID=96407941
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
index 457bbfb..b0ffbc6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
@@ -190,7 +190,8 @@
optionalPositionals = {
@Param(name = "test", type = Boolean.class, defaultValue = "False",
doc = "Whether this rule is a test rule. "
- + "If True, the rule must end with <code>_test</code> (otherwise it cannot)."),
+ + "If True, the rule must end with <code>_test</code> (otherwise it cannot), "
+ + "and there must be an action that generates <code>ctx.outputs.executable</code>."),
@Param(name = "attrs", type = Map.class, noneable = true, defaultValue = "None", doc =
"dictionary to declare all the attributes of the rule. It maps from an attribute name "
+ "to an attribute object (see <a href=\"#modules.attr\">attr</a> module). "
@@ -215,6 +216,7 @@
doc = "If true, the files will be generated in the genfiles directory instead of the "
+ "bin directory. This is used for compatibility with existing rules.")},
useAst = true, useEnvironment = true)
+ @SuppressWarnings("unused") // used via reflection.
private static final BuiltinFunction rule = new BuiltinFunction("rule") {
@SuppressWarnings({"rawtypes", "unchecked"}) // castMap produces
// an Attribute.Builder instead of a Attribute.Builder<?> but it's OK.
@@ -240,7 +242,7 @@
builder.addOrOverrideAttribute(attrBuilder.build(attrName));
}
}
- if (executable) {
+ if (executable || test) {
builder.addOrOverrideAttribute(
attr("$is_executable", BOOLEAN).value(true)
.nonconfigurable("Called from RunCommand.isExecutable, which takes a Target")