Skip to content

Commit

Permalink
Add logic for internal-only test tag
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 344149273
  • Loading branch information
Googler authored and copybara-github committed Nov 25, 2020
1 parent 6ce39b4 commit 72cd5b2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public enum WorkerProtocolFormat {
/** 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ private static ResourceSet getResourceSetFromSize(TestSize size) {
}
}

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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ public static boolean isExternalTestRule(Rule rule) {
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);
Expand Down

0 comments on commit 72cd5b2

Please sign in to comment.