Skip to content

Commit

Permalink
Windows,tests: port ui_test
Browse files Browse the repository at this point in the history
//src/test/shell/integration:ui_test
now runs on Windows.

See #4292

Change-Id: I6667e55f26b9f87437234ba949a521760cfaaa18

Closes #5872.

Change-Id: I6667e55f26b9f87437234ba949a521760cfaaa18
PiperOrigin-RevId: 208476786
  • Loading branch information
laszlocsomor authored and Copybara-Service committed Aug 13, 2018
1 parent e20d8ca commit ea168de
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/test/shell/integration/BUILD
Expand Up @@ -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(
Expand Down
67 changes: 53 additions & 14 deletions src/test/shell/integration/ui_test.sh
Expand Up @@ -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"],
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -73,5 +113,4 @@ function test_noline_wrapping_color_nocurses() {
expect_not_log '\\$'
}


run_suite "Basic integration tests for the standard UI"

0 comments on commit ea168de

Please sign in to comment.