From 73fc71376aa2ff6b3f5c7d28b3dfb01af153cbd6 Mon Sep 17 00:00:00 2001 From: John Hood Date: Sun, 28 May 2017 16:22:49 -0400 Subject: [PATCH] Add a pause mechanism for debugging tests. --- src/tests/e2e-test-server | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/tests/e2e-test-server b/src/tests/e2e-test-server index 146943d..fc6d15a 100755 --- a/src/tests/e2e-test-server +++ b/src/tests/e2e-test-server @@ -5,6 +5,29 @@ # then captures screen with `tmux capture-pane`. Captures exitstatus # of both and returns appropriate errors. # + +# If MOSH_E2E_WAIT is set, then the test will wait for another tmux +# client to attach to the test session before starting, and will wait +# for other tmux clients to detach before exiting. +wait_for_clients() +{ + if [ -z "$MOSH_E2E_WAIT" ]; then + return + fi + expected=$1 + while true; do + n=$(tmux list-clients -F . | wc -l) + if [ $expected -eq 1 ]; then + if [ $n -eq 1 ]; then + return + fi + elif [ $n -ne 1 ]; then + return + fi + sleep 1 + done +} + export MOSH_SERVER_PID=$PPID if [ $# -lt 2 ]; then @@ -26,6 +49,7 @@ if [ -z "$TMUX_PANE" ]; then printf "not running under tmux\n" >&2 exit 99 fi +wait_for_clients 2 # run harnessed command eval "$@" testret=$? @@ -37,6 +61,7 @@ fi # Wait for tmux client screen to become up to date. sleep 1 printf "@@@ server complete @@@" >&2 +wait_for_clients 1 i=0 while [ $i -lt 60 ]; do if grep -q "@@@ server complete @@@" "$testname.tmux.log"; then