aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-03-09 22:09:14 +0000
committerGravatar David Chen <dzc@google.com>2016-03-10 10:22:37 +0000
commitbe7176811f77dd58de763c7ac24d5fb7f849c5c0 (patch)
treedbdcea753c8f86269e89bb38097716a9e19cba6c
parent4e4ffd2778fdad30c16384872fe6a92f5355f43f (diff)
Make the bazel_worker_test non-flaky, once and for all.
-- MOS_MIGRATED_REVID=116801400
-rwxr-xr-xsrc/test/shell/bazel/bazel_worker_test.sh37
-rw-r--r--src/test/shell/unittest.bash6
2 files changed, 4 insertions, 39 deletions
diff --git a/src/test/shell/bazel/bazel_worker_test.sh b/src/test/shell/bazel/bazel_worker_test.sh
index 229d4ba033..61ee9eafc4 100755
--- a/src/test/shell/bazel/bazel_worker_test.sh
+++ b/src/test/shell/bazel/bazel_worker_test.sh
@@ -27,24 +27,7 @@ source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \
example_worker=$(find $TEST_SRCDIR -name ExampleWorker_deploy.jar)
function set_up() {
- workers=$(print_workers)
- if [[ ! -z "${workers}" ]]; then
- kill $workers
-
- # Wait at most 10 seconds for all workers to shut down.
- for i in 0 1 2 3 4 5 6 7 8 9; do
- still_running_workers=$(for pid in $workers; do kill -0 $pid &>/dev/null && echo $pid || true; done)
-
- if [[ ! -z "${still_running_workers}" ]]; then
- if [[ $i -eq 3 ]]; then
- kill -TERM $still_running_workers
- fi
-
- sleep 1
- fi
- done
- fi
-
+ bazel build --worker_quit_after_build
assert_workers_not_running
}
@@ -90,23 +73,6 @@ function print_workers() {
pgrep -P $pid || true
}
-function shutdown_and_print_unkilled_workers() {
- workers=$(print_workers)
- bazel shutdown || fail "shutdown failed"
-
- # Wait at most 10 seconds for all workers to shut down, then print the remaining (if any).
- for i in 0 1 2 3 4 5 6 7 8 9; do
- still_running_workers=$(for pid in $workers; do kill -0 $pid &>/dev/null && echo $pid || true; done)
- if [[ ! -z "${still_running_workers}" ]]; then
- sleep 1
- fi
- done
-
- if [ ! -z "$still_running_workers" ]; then
- fail "Worker processes were still running after shutdown: ${unkilled_workers}"
- fi
-}
-
function assert_workers_running() {
workers=$(print_workers)
if [[ -z "${workers}" ]]; then
@@ -128,7 +94,6 @@ function test_compiles_hello_library_using_persistent_javac() {
bazel-bin/java/main/main | grep -q "Hello, Library!;Hello, World!" \
|| fail "comparison failed"
assert_workers_running
- shutdown_and_print_unkilled_workers
}
function test_workers_quit_after_build() {
diff --git a/src/test/shell/unittest.bash b/src/test/shell/unittest.bash
index c31d0eb33c..acdf06bb77 100644
--- a/src/test/shell/unittest.bash
+++ b/src/test/shell/unittest.bash
@@ -190,7 +190,7 @@ function timeout() {
:
}
-# Usage: fail <message>
+# Usage: fail <message> [<message> ...]
# Print failure message with context information, and mark the test as
# a failure. The context includes a stacktrace including the longest sequence
# of calls outside this module. (We exclude the top and bottom portions of
@@ -198,8 +198,8 @@ function timeout() {
# $TEST_log.
function fail() {
__show_log >&2
- echo "$TEST_name FAILED: $1." >&2
- echo "$1" >$TEST_TMPDIR/__fail
+ echo "$TEST_name FAILED:" "$@" "." >&2
+ echo "$@" >$TEST_TMPDIR/__fail
TEST_passed="false"
__show_stack
# Cleanup as we are leaving the subshell now