From ea168de2b7929277366ba27028fc4c8af2fa9235 Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Mon, 13 Aug 2018 07:22:47 -0700 Subject: 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 --- src/test/shell/integration/BUILD | 6 ++-- src/test/shell/integration/ui_test.sh | 67 +++++++++++++++++++++++++++-------- 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 < $pkg/true.sh < pkg/BUILD < $pkg/BUILD <$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" -- cgit v1.2.3