Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow exec groups to inherit from the rule or other exec groups. #13119

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,16 @@ public static LabelLateBoundDefault<BuildConfiguration> getCoverageOutputGenerat
return runUnder != null ? runUnder.getLabel() : null;
});

public static final String TEST_RUNNER_EXEC_GROUP = "test";

/**
* A base rule for all test rules.
*/
public static final class TestBaseRule implements RuleDefinition {
@Override
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
return builder
.addExecGroup(TEST_RUNNER_EXEC_GROUP)
.requiresConfigurationFragments(TestConfiguration.class)
// TestConfiguration only needed to create TestAction and TestProvider
// Only necessary at top-level and can be skipped if trimmed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

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

import static com.google.devtools.build.lib.analysis.BaseRuleClasses.TEST_RUNNER_EXEC_GROUP;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionOwner;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ArtifactRoot;
import com.google.devtools.build.lib.actions.RunfilesSupplier;
Expand Down Expand Up @@ -147,6 +149,11 @@ private boolean isPersistentTestRunner() {
&& persistentTestRunnerRunfiles != null;
}

private ActionOwner getOwner() {
ActionOwner owner = ruleContext.getActionOwner(TEST_RUNNER_EXEC_GROUP);
return owner == null ? ruleContext.getActionOwner() : owner;
}

/**
* Creates a test action and artifacts for the given rule. The test action will use the specified
* executable and runfiles.
Expand Down Expand Up @@ -403,7 +410,7 @@ private TestParams createTestAction(int shards)
boolean splitCoveragePostProcessing = testConfiguration.splitCoveragePostProcessing();
TestRunnerAction testRunnerAction =
new TestRunnerAction(
ruleContext.getActionOwner(),
getOwner(),
inputs,
testRunfilesSupplier,
testActionExecutable,
Expand Down