summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hood <cgull@glup.org>2017-05-28 16:22:49 -0400
committerJohn Hood <cgull@glup.org>2017-05-28 19:28:04 -0400
commit73fc71376aa2ff6b3f5c7d28b3dfb01af153cbd6 (patch)
tree99be8bcd464dfc45dc56b3a463be8fa460663628
parentd15d342df324a443405bddaeef8859324244c8cf (diff)
Add a pause mechanism for debugging tests.
-rwxr-xr-xsrc/tests/e2e-test-server25
1 files changed, 25 insertions, 0 deletions
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