aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-08-13 07:22:47 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-13 07:24:17 -0700
commitea168de2b7929277366ba27028fc4c8af2fa9235 (patch)
tree6c9ae0eb85ea7efccd06a8e877b72e482fe834f8
parente20d8ca9b76782e0f46c3b60399c7e3730523039 (diff)
Windows,tests: port ui_test
//src/test/shell/integration:ui_test now runs on Windows. See https://github.com/bazelbuild/bazel/issues/4292 Change-Id: I6667e55f26b9f87437234ba949a521760cfaaa18 Closes #5872. Change-Id: I6667e55f26b9f87437234ba949a521760cfaaa18 PiperOrigin-RevId: 208476786
-rw-r--r--src/test/shell/integration/BUILD6
-rwxr-xr-xsrc/test/shell/integration/ui_test.sh67
2 files changed, 57 insertions, 16 deletions
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index 4b3b7f28f2..d9c867d1cc 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -250,8 +250,10 @@ sh_test(
name = "ui_test",
size = "medium",
srcs = ["ui_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/ui_test.sh b/src/test/shell/integration/ui_test.sh
index 4fb046d932..de227c92e8 100755
--- a/src/test/shell/integration/ui_test.sh
+++ b/src/test/shell/integration/ui_test.sh
@@ -16,23 +16,57 @@
#
# An end-to-end test that Bazel's experimental UI produces reasonable output.
-# 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
-function set_up() {
- mkdir -p pkg
- cat > pkg/true.sh <<EOF
+#### SETUP #############################################################
+
+function create_pkg() {
+ local -r pkg=$1
+ mkdir -p $pkg
+ cat > $pkg/true.sh <<EOF
#!/bin/sh
exit 0
EOF
- chmod 755 pkg/true.sh
- cat > pkg/BUILD <<EOF
+ chmod 755 $pkg/true.sh
+ cat > $pkg/BUILD <<EOF
sh_test(
name = "true",
srcs = ["true.sh"],
@@ -43,7 +77,9 @@ EOF
#### TESTS #############################################################
function test_basic_progress() {
- bazel test --curses=yes --color=yes pkg:true 2>$TEST_log || fail "bazel test failed"
+ local -r pkg=$FUNCNAME
+ create_pkg $pkg
+ bazel test --curses=yes --color=yes $pkg:true 2>$TEST_log || fail "bazel test failed"
# some progress indicator is shown
expect_log '\[[0-9,]* / [0-9,]*\]'
# something is written in green
@@ -53,7 +89,9 @@ function test_basic_progress() {
}
function test_line_wrapping() {
- bazel test --curses=yes --color=yes --terminal_columns=5 pkg:true 2>$TEST_log || fail "bazel test failed"
+ local -r pkg=$FUNCNAME
+ create_pkg $pkg
+ bazel test --curses=yes --color=yes --terminal_columns=5 $pkg:true 2>$TEST_log || fail "bazel test failed"
# curses are used to delete at least one line
expect_log $'\x1b\[1A\x1b\[K'
# something is written in green
@@ -63,7 +101,9 @@ function test_line_wrapping() {
}
function test_noline_wrapping_color_nocurses() {
- bazel test --curses=no --color=yes --terminal_columns=5 pkg:true 2>$TEST_log || fail "bazel test failed"
+ local -r pkg=$FUNCNAME
+ create_pkg $pkg
+ bazel test --curses=no --color=yes --terminal_columns=5 $pkg:true 2>$TEST_log || fail "bazel test failed"
# something is written in green
expect_log $'\x1b\[32m'
# no lines are deleted
@@ -73,5 +113,4 @@ function test_noline_wrapping_color_nocurses() {
expect_not_log '\\$'
}
-
run_suite "Basic integration tests for the standard UI"