aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-08-14 00:27:42 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-14 00:29:37 -0700
commitf7f5876b726f104696d8d337e9f514987d1f1030 (patch)
tree7d3c3e8dc231283dcb4cb8286f286c8b857d1e02
parente5719662a91a7eb310eb0ea528992c49090784c9 (diff)
Windows,tests: port incomp._changes_conflict_test
//src/test/shell/integration:incompatible_changes_conflict_test now runs on Windows. See https://github.com/bazelbuild/bazel/issues/4292 Change-Id: I9f599b3ac8e85f394320989a71c00547b493efca Closes #5870. Change-Id: I7fa6db3df8d5d06ac2849d538ed6d84030cb1069 PiperOrigin-RevId: 208604220
-rw-r--r--src/test/shell/integration/BUILD6
-rwxr-xr-xsrc/test/shell/integration/incompatible_changes_conflict_test.sh49
2 files changed, 50 insertions, 5 deletions
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index 66e8eb3688..e496e69c63 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -234,8 +234,10 @@ sh_test(
size = "small",
timeout = "moderate",
srcs = ["incompatible_changes_conflict_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/incompatible_changes_conflict_test.sh b/src/test/shell/integration/incompatible_changes_conflict_test.sh
index 81b549d870..c92f0577e1 100755
--- a/src/test/shell/integration/incompatible_changes_conflict_test.sh
+++ b/src/test/shell/integration/incompatible_changes_conflict_test.sh
@@ -19,11 +19,54 @@
# it is difficult to know in a unit test exactly what features (OptionsBase
# subclasses) are passed to the parser from within a unit test.
-# 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; }
+# `uname` returns the current platform, e.g "MSYS_NT-10.0" or "Linux".
+# `tr` converts all upper case letters to lower case.
+# `case` matches the result if the `uname | tr` expression to string prefixes
+# that use the same wildcards as names do in Bash, i.e. "msys*" matches strings
+# starting with "msys", and "*" matches everything (it's the default case).
+case "$(uname -s | tr [:upper:] [:lower:])" in
+msys*)
+ # As of 2018-08-14, Bazel on Windows only supports MSYS Bash.
+ declare -r is_windows=true
+ ;;
+*)
+ declare -r is_windows=false
+ ;;
+esac
+
+if "$is_windows"; then
+ # Disable MSYS path conversion that converts path-looking command arguments to
+ # Windows paths (even if they arguments are not in fact paths).
+ export MSYS_NO_PATHCONV=1
+ export MSYS2_ARG_CONV_EXCL="*"
+fi
+
# The clash canary flags are built into the canonicalize-flags command
# specifically for this test suite.
canary_clash_error="option '--flag_clash_canary' was expanded to from both "