aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-08-18 14:24:58 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-08-18 17:25:32 +0000
commit88de40ee8bf2248fbf2264a7725170e0a83ee84c (patch)
treef0fd54f81ef0efb454d76feca2c7b7c4bc56dfbd /src/main/java/com/google/devtools/build
parent837dbc1739258d72a5e7c4adb37ffe6aff847672 (diff)
Fix tmpdir with standalone test strategy
If the tmpdir wasn't below the execroot, Bazel would crash and print a stack trace. Also, the test was incorrect because the EOF wasn't quoted, so it was actually just executing "echo TEST_TMPDIR=/path/to/tmpdir" which (surprise surprise) matched TEST_TMPDIR=/path/to/tmpdir. Finally, the test was _also_ incorrect because it was using the cached test result for the second case, since changing the tmpdir doesn't invalidate the test result. So it not only was comparing a constant string to a constant string, but it wasn't even re-evaluating the constant string. -- MOS_MIGRATED_REVID=130637221
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
index f2af631375..2651b72b7c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
@@ -155,11 +155,18 @@ public class StandaloneTestStrategy extends TestStrategy {
vars.putAll(config.getLocalShellEnvironment());
vars.putAll(action.getTestEnv());
+ String tmpDirString;
+ if (tmpDir.startsWith(execRoot)) {
+ tmpDirString = tmpDir.relativeTo(execRoot).getPathString();
+ } else {
+ tmpDirString = tmpDir.getPathString();
+ }
+
String testSrcDir = runfilesDir.relativeTo(execRoot).getPathString();
vars.put("JAVA_RUNFILES", testSrcDir);
vars.put("PYTHON_RUNFILES", testSrcDir);
vars.put("TEST_SRCDIR", testSrcDir);
- vars.put("TEST_TMPDIR", tmpDir.relativeTo(execRoot).getPathString());
+ vars.put("TEST_TMPDIR", tmpDirString);
vars.put("TEST_WORKSPACE", action.getRunfilesPrefix());
vars.put("XML_OUTPUT_FILE", xmlOutputPath.relativeTo(execRoot).getPathString());
if (!action.isEnableRunfiles()) {