Skip to content

Commit 1e258d2

Browse files
katrecopybara-github
authored andcommitted
Allow exec groups to inherit from the rule or other exec groups.
Work towards #12006. Add a "test" exec group for TestRunnerActions. This will allow users to set {"test.key", "value"} inside their exec properties and {"key", "value"} will propagate as to just TestRunnerActions. This addresses user request #10799 This is a rollforward of c1ae939, which was reverted in c266ac9. Closes #13119. PiperOrigin-RevId: 360168649
1 parent f9a93fd commit 1e258d2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,16 @@ public static LabelLateBoundDefault<BuildConfiguration> getCoverageOutputGenerat
147147
return runUnder != null ? runUnder.getLabel() : null;
148148
});
149149

150+
public static final String TEST_RUNNER_EXEC_GROUP = "test";
151+
150152
/**
151153
* A base rule for all test rules.
152154
*/
153155
public static final class TestBaseRule implements RuleDefinition {
154156
@Override
155157
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
156158
return builder
159+
.addExecGroup(TEST_RUNNER_EXEC_GROUP)
157160
.requiresConfigurationFragments(TestConfiguration.class)
158161
// TestConfiguration only needed to create TestAction and TestProvider
159162
// Only necessary at top-level and can be skipped if trimmed.

src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
package com.google.devtools.build.lib.analysis.test;
1616

17+
import static com.google.devtools.build.lib.analysis.BaseRuleClasses.TEST_RUNNER_EXEC_GROUP;
1718
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
1819

1920
import com.google.common.base.Preconditions;
2021
import com.google.common.collect.ImmutableList;
2122
import com.google.common.collect.Lists;
2223
import com.google.devtools.build.lib.actions.ActionInput;
24+
import com.google.devtools.build.lib.actions.ActionOwner;
2325
import com.google.devtools.build.lib.actions.Artifact;
2426
import com.google.devtools.build.lib.actions.ArtifactRoot;
2527
import com.google.devtools.build.lib.actions.RunfilesSupplier;
@@ -147,6 +149,11 @@ private boolean isPersistentTestRunner() {
147149
&& persistentTestRunnerRunfiles != null;
148150
}
149151

152+
private ActionOwner getOwner() {
153+
ActionOwner owner = ruleContext.getActionOwner(TEST_RUNNER_EXEC_GROUP);
154+
return owner == null ? ruleContext.getActionOwner() : owner;
155+
}
156+
150157
/**
151158
* Creates a test action and artifacts for the given rule. The test action will use the specified
152159
* executable and runfiles.
@@ -403,7 +410,7 @@ private TestParams createTestAction(int shards)
403410
boolean splitCoveragePostProcessing = testConfiguration.splitCoveragePostProcessing();
404411
TestRunnerAction testRunnerAction =
405412
new TestRunnerAction(
406-
ruleContext.getActionOwner(),
413+
getOwner(),
407414
inputs,
408415
testRunfilesSupplier,
409416
testActionExecutable,

0 commit comments

Comments
 (0)