diff options
author | Ulf Adams <ulfjack@google.com> | 2016-12-16 14:31:42 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-12-16 15:37:54 +0000 |
commit | b21cfa12b83072bcb6d7e700542e7051a7d21bce (patch) | |
tree | a1f51046f42c7651f491cd8d5ec6d7c245eee563 /src/main/java/com | |
parent | c8ac9187b0e62f9758095e479d85680c6f5c780c (diff) |
Continued TestStrategy refactoring.
More renaming and some reformatting to make StandaloneTestStrategy more
closely resemble the internal implementation of TestStrategy.
--
PiperOrigin-RevId: 142254302
MOS_MIGRATED_REVID=142254302
Diffstat (limited to 'src/main/java/com')
3 files changed, 21 insertions, 31 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java index dcc986a28e..fb9216d209 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java @@ -59,15 +59,15 @@ public class StandaloneTestStrategy extends TestStrategy { public static final String COLLECT_COVERAGE = "external/bazel_tools/tools/test/collect_coverage.sh"; - protected final Path workspace; + protected final Path tmpDirRoot; public StandaloneTestStrategy( OptionsClassProvider requestOptions, BinTools binTools, Map<String, String> clientEnv, - Path workspace) { + Path tmpDirRoot) { super(requestOptions, binTools, clientEnv); - this.workspace = workspace; + this.tmpDirRoot = tmpDirRoot; } @Override @@ -83,8 +83,8 @@ public class StandaloneTestStrategy extends TestStrategy { action.getLocalShellEnvironment(), action.isEnableRunfiles()); Path tmpDir = - getTmpRoot(workspace, execRoot, executionOptions) - .getChild(getTmpDirName(action.getExecutionSettings().getExecutable().getExecPath())); + tmpDirRoot.getChild( + getTmpDirName(action.getExecutionSettings().getExecutable().getExecPath())); Map<String, String> env = setupEnvironment(action, execRoot, runfilesDir, tmpDir); Path workingDirectory = runfilesDir.getRelative(action.getRunfilesPrefix()); @@ -97,16 +97,13 @@ public class StandaloneTestStrategy extends TestStrategy { try (FileOutErr fileOutErr = new FileOutErr( - action.getTestLog().getPath(), - action - .resolve(actionExecutionContext.getExecutor().getExecRoot()) - .getTestStderr()); + action.getTestLog().getPath(), action.resolve(execRoot).getTestStderr()); ResourceHandle handle = ResourceManager.instance().acquireResources(action, resources)) { TestResultData data = - execute( + executeTest( + action, actionExecutionContext.withFileOutErr(fileOutErr), env, - action, execRoot, runfilesDir); appendStderr(fileOutErr.getOutputPath(), fileOutErr.getErrorPath()); @@ -155,10 +152,10 @@ public class StandaloneTestStrategy extends TestStrategy { return env; } - protected TestResultData execute( + protected TestResultData executeTest( + TestRunnerAction action, ActionExecutionContext actionExecutionContext, Map<String, String> environment, - TestRunnerAction action, Path execRoot, Path runfilesDir) throws ExecException, InterruptedException, IOException { diff --git a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java index 94b9d0da2d..668e76b313 100644 --- a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java +++ b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.exec.ExecutionOptions; import com.google.devtools.build.lib.exec.FileWriteStrategy; import com.google.devtools.build.lib.exec.StandaloneTestStrategy; +import com.google.devtools.build.lib.exec.TestStrategy; import com.google.devtools.build.lib.rules.cpp.IncludeScanningContext; import com.google.devtools.build.lib.rules.cpp.SpawnGccStrategy; import com.google.devtools.build.lib.rules.cpp.SpawnLinkStrategy; @@ -33,6 +34,7 @@ import com.google.devtools.build.lib.rules.test.ExclusiveTestStrategy; import com.google.devtools.build.lib.rules.test.TestActionContext; import com.google.devtools.build.lib.runtime.CommandEnvironment; import com.google.devtools.build.lib.vfs.FileSystemUtils; +import com.google.devtools.build.lib.vfs.Path; import java.io.IOException; /** @@ -67,12 +69,13 @@ public class StandaloneActionContextProvider extends ActionContextProvider { public StandaloneActionContextProvider(CommandEnvironment env, BuildRequest buildRequest) { this.env = env; - boolean verboseFailures = buildRequest.getOptions(ExecutionOptions.class).verboseFailures; + ExecutionOptions options = buildRequest.getOptions(ExecutionOptions.class); + boolean verboseFailures = options.verboseFailures; + Path testTmpRoot = TestStrategy.getTmpRoot(env.getWorkspace(), env.getExecRoot(), options); TestActionContext testStrategy = new StandaloneTestStrategy( - buildRequest, env.getBlazeWorkspace().getBinTools(), env.getClientEnv(), - env.getWorkspace()); + buildRequest, env.getBlazeWorkspace().getBinTools(), env.getClientEnv(), testTmpRoot); Builder<ActionContext> strategiesBuilder = ImmutableList.builder(); diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java index cf073065a0..29a23fe66e 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerTestStrategy.java @@ -77,28 +77,23 @@ public class WorkerTestStrategy extends StandaloneTestStrategy { } @Override - protected TestResultData execute( + protected TestResultData executeTest( + TestRunnerAction action, ActionExecutionContext actionExecutionContext, Map<String, String> environment, - TestRunnerAction action, Path execRoot, Path runfilesDir) throws ExecException, InterruptedException, IOException { List<String> startupArgs = getStartUpArgs(action); return execInWorker( - actionExecutionContext, - environment, - action, - startupArgs, - execRoot, - maxRetries); + action, actionExecutionContext, environment, startupArgs, execRoot, maxRetries); } private TestResultData execInWorker( + TestRunnerAction action, ActionExecutionContext actionExecutionContext, Map<String, String> environment, - TestRunnerAction action, List<String> startupArgs, Path execRoot, int retriesLeft) @@ -177,12 +172,7 @@ public class WorkerTestStrategy extends StandaloneTestStrategy { + e + "), invalidating and retrying with new worker...")); return execInWorker( - actionExecutionContext, - environment, - action, - startupArgs, - execRoot, - retriesLeft - 1); + action, actionExecutionContext, environment, startupArgs, execRoot, retriesLeft - 1); } else { throw new TestExecException(e.getMessage()); } |