diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2018-07-27 07:36:32 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-27 07:37:44 -0700 |
commit | a0276dd265ead59d9a0e8fa1090ff94e38e3fedc (patch) | |
tree | ba35fbec0835f28d52cfc615700af90526f34e7f | |
parent | 64560dd74f5494e8cd0ac80904a13889f83e526f (diff) |
Windows,tests: port progress_reporting_test
//src/test/shell/integration:progress_reporting_test
now runs on Windows.
See https://github.com/bazelbuild/bazel/issues/4292
Change-Id: Ic6a4c466156e26717beacb3bbbb270a8c2ccccd0
Closes #5675.
Change-Id: I4152dbe38a9880cbdad5d897b3d8b082b200552b
PiperOrigin-RevId: 206315309
-rw-r--r-- | src/test/shell/integration/BUILD | 8 | ||||
-rwxr-xr-x | src/test/shell/integration/progress_reporting_test.sh | 74 |
2 files changed, 63 insertions, 19 deletions
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD index bd588727e9..87d7ed51ec 100644 --- a/src/test/shell/integration/BUILD +++ b/src/test/shell/integration/BUILD @@ -18,9 +18,11 @@ sh_test( name = "progress_reporting_test", size = "large", srcs = ["progress_reporting_test.sh"], - data = [":test-deps"], - shard_count = 8, - tags = ["no_windows"], + data = [ + ":test-deps", + "@bazel_tools//tools/bash/runfiles", + ], + shard_count = 4, ) sh_test( diff --git a/src/test/shell/integration/progress_reporting_test.sh b/src/test/shell/integration/progress_reporting_test.sh index 7d9ea60a4c..7ed4fdf1b4 100755 --- a/src/test/shell/integration/progress_reporting_test.sh +++ b/src/test/shell/integration/progress_reporting_test.sh @@ -16,16 +16,54 @@ # # This test exercises action progress reporting. -# 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 --- +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; } -set -eu +case "$(uname -s | tr [:upper:] [:lower:])" in +msys*|mingw*|cygwin*) + declare -r is_windows=true + ;; +*) + declare -r is_windows=false + ;; +esac + +if "$is_windows"; then + export MSYS_NO_PATHCONV=1 + export MSYS2_ARG_CONV_EXCL="*" + declare -r WORKSPACE_STATUS="$(cygpath -m "$(mktemp -d "${TEST_TMPDIR}/wscXXXXXXXX")/wsc.bat")" + touch "$WORKSPACE_STATUS" +else + declare -r WORKSPACE_STATUS="$(mktemp -d "${TEST_TMPDIR}/wscXXXXXXXX")/wsc.sh" + echo "#!$(which true)" > "$WORKSPACE_STATUS" + chmod +x "$WORKSPACE_STATUS" +fi # TODO(b/37617303): make tests UI-independent add_to_bazelrc "build --noexperimental_ui" -add_to_bazelrc "build --workspace_status_command=$(which true) --nostamp" +add_to_bazelrc "build --workspace_status_command=\"$WORKSPACE_STATUS\" --nostamp" add_to_bazelrc "build --show_progress_rate_limit=-1" add_to_bazelrc "build --genrule_strategy=local" @@ -149,15 +187,19 @@ EOF # waiting" message. Do not modify the workspace status writer action # implementation to have a progress message, because it breaks all kinds of # things. - cat >"${pkg}/workspace_status.sh" <<EOF -#!/bin/sh -sleep 5 -EOF - - chmod +x "${pkg}/workspace_status.sh" + if "$is_windows"; then + local -r wsc="$(cygpath -m "$(mktemp -d "${TEST_TMPDIR}/wscXXXXXXXX")/wsc.bat")" + # Wait for an event that never comes, give up after 5 seconds (exits with + # nonzero), then "cd ." to reset %ERRORLEVEL%. + echo "%SYSTEMROOT%\\system32\\waitfor.exe DummyEventToWaitFor /T 5 2>NUL & cd ." > "$wsc" + else + local -r wsc="$(mktemp -d "${TEST_TMPDIR}/wscXXXXXXXX")/wsc.sh" + echo -e "#!$(which sh)\nsleep 5" > "$wsc" + chmod +x "$wsc" + fi bazel build "//${pkg}:x" --show_task_finish --color=no --curses=no \ - --workspace_status_command="${pkg}/workspace_status.sh" \ + --workspace_status_command="$wsc" \ --progress_report_interval=1 \ >& "$TEST_log" || fail "build failed" @@ -234,13 +276,13 @@ EOF # last one might be the workspace status writer action). echo "input-clean" > "${pkg}/input" - bazel --nobatch build "//${pkg}:x" --show_task_finish --color=no --curses=no \ + bazel build "//${pkg}:x" --show_task_finish --color=no --curses=no \ >& "$TEST_log" || fail "build failed" expect_log_once "\[[89] / 9\] Executing genrule //${pkg}:x DONE" expect_log_n "\[[1-9] / 9\] Executing genrule //${pkg}:.* DONE" 8 echo "input-incremental" > "${pkg}/input" - bazel --nobatch build "//${pkg}:x" --show_task_finish --color=no --curses=no \ + bazel build "//${pkg}:x" --show_task_finish --color=no --curses=no \ >& "$TEST_log" || fail "build failed" expect_log_once "\[[89] / 9\] Executing genrule //${pkg}:x DONE" expect_log_n "\[[1-9] / 9\] Executing genrule //${pkg}:.* DONE" 2 @@ -328,13 +370,13 @@ EOF # The last action should again be target "x", its completion index 8 or 9 (the # last one might be the workspace status writer action). echo "input-clean" > "${pkg}/input" - bazel --nobatch build "//${pkg}:x" --show_task_finish --color=no --curses=no \ + bazel build "//${pkg}:x" --show_task_finish --color=no --curses=no \ >& "$TEST_log" || fail "build failed" expect_log_once "\[[89] / 9\] Executing genrule //${pkg}:x DONE" expect_log_n "\[[1-9] / 9\] Executing genrule //${pkg}:.* DONE" 8 echo "input-incremental" > "${pkg}/input" - bazel --nobatch build "//${pkg}:x" --show_task_finish --color=no --curses=no \ + bazel build "//${pkg}:x" --show_task_finish --color=no --curses=no \ >& "$TEST_log" || fail "build failed" expect_log_once "\[[12] / 9\] Executing genrule //${pkg}:dep1 DONE" expect_log_once "Executing genrule .* DONE" |