aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-08-13 07:55:42 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-13 07:59:19 -0700
commitd73e5902d877c94d9a13de27e1dc09bb45da4e72 (patch)
tree765b4356f8777d5db134fdfa8eb3a6fabedb10f4
parent90729a57a865c08fe561be6a49734582becfbb53 (diff)
Windows,tests: port rc_options_test
//src/test/shell/integration:rc_options_test now runs on Windows. See https://github.com/bazelbuild/bazel/issues/4292 Change-Id: I1fe42e1477e9ebfb94ccfb896de4af5a72e3bb61 Closes #5873. Change-Id: I1fe42e1477e9ebfb94ccfb896de4af5a72e3bb61 PiperOrigin-RevId: 208479907
-rw-r--r--src/test/shell/integration/BUILD6
-rwxr-xr-xsrc/test/shell/integration/rc_options_test.sh62
2 files changed, 54 insertions, 14 deletions
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index d9c867d1cc..4717180d16 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -260,8 +260,10 @@ sh_test(
name = "rc_options_test",
size = "medium",
srcs = ["rc_options_test.sh"],
- data = [":test-deps"],
- tags = ["no_windows"],
+ data = [
+ ":test-deps",
+ "@bazel_tools//tools/bash/runfiles",
+ ],
)
sh_test(
diff --git a/src/test/shell/integration/rc_options_test.sh b/src/test/shell/integration/rc_options_test.sh
index 6909e3da7d..e6f7e71cb0 100755
--- a/src/test/shell/integration/rc_options_test.sh
+++ b/src/test/shell/integration/rc_options_test.sh
@@ -16,26 +16,60 @@
#
# An end-to-end test for Bazel's option handling
-# Load the test setup defined in the parent directory
-CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-source "${CURRENT_DIR}/../integration_test_setup.sh" \
+# --- begin runfiles.bash initialization ---
+# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
+set -euo pipefail
+if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ if [[ -f "$0.runfiles_manifest" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
+ elif [[ -f "$0.runfiles/MANIFEST" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
+ elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
-#### SETUP #############################################################
+case "$(uname -s | tr [:upper:] [:lower:])" in
+msys*|mingw*|cygwin*)
+ declare -r is_windows=true
+ ;;
+*)
+ declare -r is_windows=false
+ ;;
+esac
-set -e
+if "$is_windows"; then
+ export MSYS_NO_PATHCONV=1
+ export MSYS2_ARG_CONV_EXCL="*"
+fi
+
+#### SETUP #############################################################
add_to_bazelrc "build --terminal_columns=6"
-function set_up() {
- mkdir -p pkg
+function create_pkg() {
+ local -r pkg=$1
+ mkdir -p $pkg
# have test with a long name, to be able to test line breaking in the output
- cat > pkg/xxxxxxxxxxxxxxxxxxxxxxxxxtrue.sh <<EOF
+ cat > $pkg/xxxxxxxxxxxxxxxxxxxxxxxxxtrue.sh <<EOF
#!/bin/sh
exit 0
EOF
- chmod 755 pkg/xxxxxxxxxxxxxxxxxxxxxxxxxtrue.sh
- cat > pkg/BUILD <<EOF
+ chmod 755 $pkg/xxxxxxxxxxxxxxxxxxxxxxxxxtrue.sh
+ cat > $pkg/BUILD <<EOF
sh_test(
name = "xxxxxxxxxxxxxxxxxxxxxxxxxtrue",
srcs = ["xxxxxxxxxxxxxxxxxxxxxxxxxtrue.sh"],
@@ -46,8 +80,10 @@ EOF
#### TESTS #############################################################
function test_terminal_columns_honored() {
+ local -r pkg=$FUNCNAME
+ create_pkg $pkg
bazel test --curses=yes --color=yes --nocache_test_results \
- pkg:xxxxxxxxxxxxxxxxxxxxxxxxxtrue \
+ $pkg:xxxxxxxxxxxxxxxxxxxxxxxxxtrue \
2>$TEST_log || fail "bazel test failed"
# the lines are wrapped to 6 characters
expect_log '^xxxx'
@@ -55,9 +91,11 @@ function test_terminal_columns_honored() {
}
function test_options_override() {
+ local -r pkg=$FUNCNAME
+ create_pkg $pkg
bazel test --curses=yes --color=yes --terminal_columns=10 \
--nocache_test_results \
- pkg:xxxxxxxxxxxxxxxxxxxxxxxxxtrue 2>$TEST_log || fail "bazel test failed"
+ $pkg:xxxxxxxxxxxxxxxxxxxxxxxxxtrue 2>$TEST_log || fail "bazel test failed"
# the lines are wrapped to 10 characters
expect_log '^xxxxxxxx'
expect_not_log '^xxxxxxxxxxx'