Add logic for internal-only test tag PiperOrigin-RevId: 344149273
diff --git a/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html b/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html index 8211580..f7a1fde 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html +++ b/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html
@@ -46,7 +46,7 @@ or cached remotely. This is equivalent to using both no-remote-cache and no-remote-exec. </li> - <li><code>local</code> keyword precludes the action or test from being remotely cached, + <li><code>local</code> keyword precludes the action or test from being remotely cached, remotely executed, or run inside the sandbox. For genrules and tests, marking the rule with the <code>local = True</code> attribute has the same effect.
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java b/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java index 0a55056..457c26a 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ExecutionRequirements.java
@@ -195,6 +195,9 @@ /** Disables remote execution of a spawn. Note: does not disable remote caching */ public static final String NO_REMOTE_EXEC = "no-remote-exec"; + /** Tag for Google internal use. Requires local execution with correct permissions. */ + public static final String NO_TESTLOASD = "no-testloasd"; + /** * Disables both remote execution and remote caching of a spawn. This is the equivalent of using * no-remote-cache and no-remote-exec together.
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java index 0456ef0..0c97167 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java
@@ -114,6 +114,11 @@ } } + if (TargetUtils.isNoTestloasdTestRule(rule)) { + executionInfo.put(ExecutionRequirements.LOCAL, ""); + executionInfo.put(ExecutionRequirements.NO_TESTLOASD, ""); + } + if (executionRequirements != null) { // This will overwrite whatever TargetUtils put there, which might be confusing. executionInfo.putAll(executionRequirements.getExecutionInfo());
diff --git a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java index 42a3fde..5221315 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java +++ b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java
@@ -146,6 +146,16 @@ return hasConstraint(rule, "external"); } + /** + * Returns true if test marked as "no-testloasd" by the appropriate keyword in the tags attribute. + * + * <p>Method assumes that passed target is a test rule, so usually it should be used only after + * isTestRule() or isTestOrTestSuiteRule(). Behavior is undefined otherwise. + */ + public static boolean isNoTestloasdTestRule(Rule rule) { + return hasConstraint(rule, "no-testloasd"); + } + public static List<String> getStringListAttr(Target target, String attrName) { Preconditions.checkArgument(target instanceof Rule); return NonconfigurableAttributeMapper.of((Rule) target).get(attrName, Type.STRING_LIST);