diff options
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java | 15 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_windows_example_test.sh | 1 | ||||
-rwxr-xr-x | src/test/shell/testenv.sh | 23 |
3 files changed, 31 insertions, 8 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); + } } /** diff --git a/src/test/shell/bazel/bazel_windows_example_test.sh b/src/test/shell/bazel/bazel_windows_example_test.sh index 74516dfad0..20c94fb5e5 100755 --- a/src/test/shell/bazel/bazel_windows_example_test.sh +++ b/src/test/shell/bazel/bazel_windows_example_test.sh @@ -33,7 +33,6 @@ fi function set_up() { copy_examples - export PATH=/c/python_27_amd64/files:$PATH EXTRA_BAZELRC="build --cpu=x64_windows_msvc" setup_bazelrc } diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index ffc1b5813d..b3ed2aec73 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -30,14 +30,29 @@ function is_windows() { fi } -# Set some enviornment variables needed on Windows. +# Set some environment variables needed on Windows. if is_windows; then - # Changing TEST_TMPDIR to avoid long path issue on Windows - TEST_TMPDIR="/c/tmp" + # TODO(philwo) remove this once we have a Bazel release that includes the CL + # moving the Windows-specific TEST_TMPDIR into TestStrategy. + TEST_TMPDIR_BASENAME="$(basename "$TEST_TMPDIR")" + export TEST_TMPDIR="c:/temp/${TEST_TMPDIR_BASENAME}" + + # Bazel (TMPDIR) and Windows (TEMP, TMP) have three envvars that specify the + # location of the temp directory... + export TMPDIR="$TEST_TMPDIR" + export TEMP="$TEST_TMPDIR" + export TMP="$TEST_TMPDIR" + export JAVA_HOME="$(ls -d C:/Program\ Files/Java/jdk* | sort | tail -n 1)" export BAZEL_SH="c:/tools/msys64/usr/bin/bash.exe" export BAZEL_VC="c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC" - export TMPDIR="c:/tmp" + if [ -x /c/Python27/python.exe ]; then + export BAZEL_PYTHON="C:/Python27/python.exe" + export PATH="/c/Python27:$PATH" + elif [ -x /c/python_27_amd64/files/python.exe ]; then + export BAZEL_PYTHON="C:/python_27_amd64/files/python.exe" + export PATH="/c/python_27_amd64/files:$PATH" + fi fi # Make the command "bazel" available for tests. |