diff options
author | 2017-03-17 13:20:10 +0000 | |
---|---|---|
committer | 2017-03-20 11:32:29 +0000 | |
commit | dd142c93fd4939aaec30726f275644ca9446fea2 (patch) | |
tree | b0ebf7a71ede2d97cc07586c8d2efc61be8f732a /src/main/java | |
parent | e226fe82eeea8983ba79954b20448d0184bd1a87 (diff) |
windows: Improve env var handling of shell integration tests.
Use a unique TEST_TMPDIR for each running test on Windows, too.
The old behavior caused shell tests to share the same TEST_TMPDIR, which
caused conflicts when multiple tests were run in parallel.
Set Bazel's TEST_TMPDIR root on Windows to c:/temp by default in
TestStrategy. This avoids tripping the 260-character limit for paths.
We still have to keep the override in testenv.sh for the time being,
because Bazel's tests are often run with the latest released Bazel and
thus we have to wait for a new Bazel release before we can remove the
TEST_TMPDIR override from testenv.sh. Once that is done, the flag
--test_tmpdir should also magically start working on Windows.
Move the Python detection logic out of bazel_windows_example_test.sh
into testenv.sh. This is better than copying that code into every new
test's set_up method.
--
PiperOrigin-RevId: 150433265
MOS_MIGRATED_REVID=150433265
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java index 9a99031dd8..c71e917542 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java @@ -286,9 +286,18 @@ public abstract class TestStrategy implements TestActionContext { * --test_tmpdir. This does not create the directory. */ public static Path getTmpRoot(Path workspace, Path execRoot, ExecutionOptions executionOptions) { - return executionOptions.testTmpDir != null - ? workspace.getRelative(executionOptions.testTmpDir).getRelative(TEST_TMP_ROOT) - : execRoot.getRelative(TEST_TMP_ROOT); + if (executionOptions.testTmpDir != null) { + return workspace.getRelative(executionOptions.testTmpDir).getRelative(TEST_TMP_ROOT); + } + switch (OS.getCurrent()) { + case WINDOWS: + // TODO(philwo) find a better way to do this + // Hardcoding this to c:/temp isn't great, but if we use a longer path, we trip the MAX_PATH + // limit of the Windows API when running bazel inside shell integration tests. + return workspace.getFileSystem().getPath("c:/temp"); + default: + return execRoot.getRelative(TEST_TMP_ROOT); + } } /** |