aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2017-02-23 00:32:59 +0000
committerGravatar Yue Gan <yueg@google.com>2017-02-23 11:32:06 +0000
commit4816cfa732b0770d5450bf04ec78dda3d4c4dfd0 (patch)
tree78d0a1b8bf45fab050a1408f60b8766e6ba956e9
parentf2eacf021097c38154820c05e9ae6aeb01883ecc (diff)
Make bazel_bootstrap_distfile_test work on Windows
-- Change-Id: Ia6c94304fded25de48eda2060c5ec11368ff172c Reviewed-on: https://cr.bazel.build/8991 PiperOrigin-RevId: 148286095 MOS_MIGRATED_REVID=148286095
-rw-r--r--src/test/shell/bazel/BUILD2
-rwxr-xr-xsrc/test/shell/bazel/bazel_bootstrap_distfile_test.sh11
-rwxr-xr-xsrc/test/shell/testenv.sh10
-rw-r--r--tools/build_defs/pkg/pkg.bzl8
4 files changed, 21 insertions, 10 deletions
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index 7694664692..df600ded1b 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -391,7 +391,7 @@ sh_test(
sh_test(
name = "bazel_bootstrap_distfile_test",
- size = "large",
+ timeout = "eternal",
srcs = ["bazel_bootstrap_distfile_test.sh"],
args = ["$(location //:bazel-distfile)"],
data = [
diff --git a/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh b/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh
index 86922735a3..2783a81ef7 100755
--- a/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh
+++ b/src/test/shell/bazel/bazel_bootstrap_distfile_test.sh
@@ -18,7 +18,7 @@
#
set -u
-DISTFILE=$(readlink $1)
+DISTFILE=$(rlocation io_bazel/${1#./})
shift 1
if [ "${JAVA_VERSION:-}" == "1.7" ] ; then
@@ -27,19 +27,20 @@ if [ "${JAVA_VERSION:-}" == "1.7" ] ; then
fi
# Load the test setup defined in the parent directory
-CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-source "${CURRENT_DIR}/../integration_test_setup.sh" \
+source $(rlocation io_bazel/src/test/shell/integration_test_setup.sh) \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
-function test_bootsrap() {
+function test_bootstrap() {
local olddir=$(pwd)
WRKDIR=$(mktemp -d ${TEST_TMPDIR}/bazelbootstrap.XXXXXXXX)
mkdir -p "${WRKDIR}" || fail "Could not create workdir"
+ trap "rm -rf \"$WRKDIR\"" EXIT
cd "${WRKDIR}" || fail "Could not change to work directory"
- unzip ${DISTFILE}
+ unzip -q ${DISTFILE}
find . -type f -exec chmod u+w {} \;
./compile.sh || fail "Expected to be able to bootstrap bazel"
./output/bazel version || fail "Generated bazel not working"
+ ./output/bazel shutdown
cd "${olddir}"
}
diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh
index 1a59e06c56..004b689524 100755
--- a/src/test/shell/testenv.sh
+++ b/src/test/shell/testenv.sh
@@ -30,6 +30,16 @@ function is_windows() {
fi
}
+# Set some enviornment variables needed on Windows.
+if is_windows; then
+ # Changing TEST_TMPDIR to avoid long path issue on Windows
+ TEST_TMPDIR="/c/tmp"
+ 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"
+fi
+
# Make the command "bazel" available for tests.
PATH_TO_BAZEL_BIN=$(rlocation io_bazel/src/bazel)
PATH_TO_BAZEL_WRAPPER="$(dirname $(rlocation io_bazel/src/test/shell/bin/bazel))"
diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl
index 3652d66dd4..b462fa3e66 100644
--- a/tools/build_defs/pkg/pkg.bzl
+++ b/tools/build_defs/pkg/pkg.bzl
@@ -45,11 +45,11 @@ def _pkg_tar_impl(ctx):
ctx.file_action(arg_file, "\n".join(args))
ctx.action(
- executable = build_tar,
- arguments = ["--flagfile=" + arg_file.path],
- inputs = ctx.files.files + ctx.files.deps + [arg_file],
+ command = "%s --flagfile=%s" % (build_tar.path, arg_file.path),
+ inputs = ctx.files.files + ctx.files.deps + [arg_file, build_tar],
outputs = [ctx.outputs.out],
- mnemonic="PackageTar"
+ mnemonic="PackageTar",
+ use_default_shell_env = True,
)