diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2018-07-31 00:26:56 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-31 00:29:03 -0700 |
commit | 2829ba4daad00fe9a389e2f85a62c45dd1cd6d41 (patch) | |
tree | 6ae8ba668de3d561edc2842da3bd19e9a5ad3be4 /src/test/shell | |
parent | 0fcae04bdf4e674087b7a6fb70d6f6a082fb4045 (diff) |
testenv.sh: do not run "bazel info" unnecessarily
testenv.sh no longer runs "bazel info bazel-bin"
and "bazel info bazel-genfiles", because the only
test that needs this information is
bazel_sandboxing_test.sh
This saves 1-2 seconds on Windows in every shell
test setup.
Also, on Windows we can safely run Bazel in a
subshell since https://github.com/bazelbuild/bazel/issues/3148 is fixed.
Change-Id: If9873221d536f1acfd4849afbfc83b94311de2bd
Closes #5707.
Change-Id: I04e37c4d5f794017a6050253d8d1b8a8ac43a6d1
PiperOrigin-RevId: 206714921
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/bazel_sandboxing_test.sh | 3 | ||||
-rwxr-xr-x | src/test/shell/testenv.sh | 23 |
2 files changed, 7 insertions, 19 deletions
diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 233b9a9d5f..70f2d4854a 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -35,6 +35,9 @@ build --spawn_strategy=sandboxed --genrule_strategy=sandboxed EOF function set_up { + export BAZEL_GENFILES_DIR=$(bazel info bazel-genfiles 2>/dev/null) + export BAZEL_BIN_DIR=$(bazel info bazel-bin 2>/dev/null) + mkdir -p examples/genrule cat << 'EOF' > examples/genrule/a.txt foo bar bz diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index c4a0c5599d..f3e7f3088d 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -398,26 +398,11 @@ function setup_clean_workspace() { [ "${new_workspace_dir}" = "${WORKSPACE_DIR}" ] \ || log_fatal "Failed to create workspace" - # On macOS, mktemp expects the template to have the Xs at the end. - # On Linux, the Xs may be anywhere. - local -r bazel_stdout="$(mktemp "${TEST_TMPDIR}/XXXXXXXX")" - local -r bazel_stderr="${bazel_stdout}.err" - # On Windows, we mustn't run Bazel in a subshell because of - # https://github.com/bazelbuild/bazel/issues/3148. - bazel info install_base >"$bazel_stdout" 2>"$bazel_stderr" \ - && export BAZEL_INSTALL_BASE=$(cat "$bazel_stdout") \ - || log_fatal "'bazel info install_base' failed, stderr: $(cat "$bazel_stderr")" - bazel info bazel-genfiles >"$bazel_stdout" 2>"$bazel_stderr" \ - && export BAZEL_GENFILES_DIR=$(cat "$bazel_stdout") \ - || log_fatal "'bazel info bazel-genfiles' failed, stderr: $(cat "$bazel_stderr")" - bazel info bazel-bin >"$bazel_stdout" 2>"$bazel_stderr" \ - && export BAZEL_BIN_DIR=$(cat "$bazel_stdout") \ - || log_fatal "'bazel info bazel-bin' failed, stderr: $(cat "$bazel_stderr")" + _BAZEL_INSTALL_BASE=$(bazel info install_base 2>/dev/null) # Shut down this server in case the tests will run Bazel in a different output # root, otherwise we could not clean up $WORKSPACE_DIR (under $TEST_TMPDIR) # once the test is finished. bazel shutdown >&/dev/null - try_with_timeout rm -f "$bazel_stdout" "$bazel_stderr" if is_windows; then export BAZEL_SH="$(cygpath --windows /bin/bash)" @@ -451,11 +436,11 @@ function cleanup_workspace() { # Clean-up the bazel install base function cleanup() { - if [ -d "${BAZEL_INSTALL_BASE:-__does_not_exists__}" ]; then - log_info "Cleaning up BAZEL_INSTALL_BASE under $BAZEL_INSTALL_BASE" + if [ -d "${_BAZEL_INSTALL_BASE:-/dev/null}" ]; then + log_info "Cleaning up _BAZEL_INSTALL_BASE under $_BAZEL_INSTALL_BASE" # Windows takes its time to shut down Bazel and we can't delete A-server.jar # until then, so just give it time and keep trying for 2 minutes. - try_with_timeout rm -fr "${BAZEL_INSTALL_BASE}" >&/dev/null + try_with_timeout rm -fr "${_BAZEL_INSTALL_BASE}" >&/dev/null fi } |