aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2018-03-26 03:15:28 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-26 03:17:15 -0700
commit7029ddcc6d5a1484549b05fd4d2d97cec4d73925 (patch)
treef7fee5054bf243fa670210670f890d1ea29111a5 /src/main/java/com/google/devtools/build/lib/runtime/commands
parent316cd7da6f6b003b853ccf7d144f395a9a557400 (diff)
Set BUILD_WORKSPACE_DIRECTORY and BUILD_WORKING_DIRECTORY when running tests, too.
RELNOTES: None. PiperOrigin-RevId: 190439262
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
index 88c9fa12b9..303502bc78 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
@@ -425,9 +425,12 @@ public class RunCommand implements BlazeCommand {
runfilesDir, commandLineArgs);
}
- Map<String, String> runEnvironment;
- Path workingDir;
+ Map<String, String> runEnvironment = new TreeMap<>();
List<String> cmdLine = new ArrayList<>();
+ Path workingDir;
+
+ runEnvironment.put("BUILD_WORKSPACE_DIRECTORY", env.getWorkspace().getPathString());
+ runEnvironment.put("BUILD_WORKING_DIRECTORY", env.getWorkingDirectory().getPathString());
if (targetToRun.getProvider(TestProvider.class) != null) {
// This is a test. Provide it with a reasonable approximation of the actual test environment
@@ -451,12 +454,12 @@ public class RunCommand implements BlazeCommand {
PathFragment relativeTmpDir = tmpDirRoot.relativeTo(env.getExecRoot());
Duration timeout = executionOptions.testTimeout.get(
testAction.getTestProperties().getTimeout());
- runEnvironment = StandaloneTestStrategy.DEFAULT_LOCAL_POLICY.computeTestEnvironment(
+ runEnvironment.putAll(StandaloneTestStrategy.DEFAULT_LOCAL_POLICY.computeTestEnvironment(
testAction,
env.getClientEnv(),
timeout,
settings.getRunfilesDir().relativeTo(env.getExecRoot()),
- relativeTmpDir.getRelative(TestStrategy.getTmpDirName(testAction)));
+ relativeTmpDir.getRelative(TestStrategy.getTmpDirName(testAction))));
workingDir = env.getExecRoot();
try {
cmdLine.addAll(TestStrategy.getArgs(testAction));
@@ -466,9 +469,6 @@ public class RunCommand implements BlazeCommand {
return BlazeCommandResult.exitCode(ExitCode.LOCAL_ENVIRONMENTAL_ERROR);
}
} else {
- runEnvironment = new TreeMap<>();
- runEnvironment.put("BUILD_WORKSPACE_DIRECTORY", env.getWorkspace().getPathString());
- runEnvironment.put("BUILD_WORKING_DIRECTORY", env.getWorkingDirectory().getPathString());
workingDir = runfilesDir;
List<String> prettyCmdLine = new ArrayList<>();
List<String> args = computeArgs(env, targetToRun, commandLineArgs);