Add a pause mechanism for debugging tests.

This commit is contained in:
John Hood
2017-05-28 16:22:49 -04:00
parent d15d342df3
commit 73fc71376a
+25
View File
@@ -5,6 +5,29 @@
# then captures screen with `tmux capture-pane`. Captures exitstatus # then captures screen with `tmux capture-pane`. Captures exitstatus
# of both and returns appropriate errors. # 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 export MOSH_SERVER_PID=$PPID
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
@@ -26,6 +49,7 @@ if [ -z "$TMUX_PANE" ]; then
printf "not running under tmux\n" >&2 printf "not running under tmux\n" >&2
exit 99 exit 99
fi fi
wait_for_clients 2
# run harnessed command # run harnessed command
eval "$@" eval "$@"
testret=$? testret=$?
@@ -37,6 +61,7 @@ fi
# Wait for tmux client screen to become up to date. # Wait for tmux client screen to become up to date.
sleep 1 sleep 1
printf "@@@ server complete @@@" >&2 printf "@@@ server complete @@@" >&2
wait_for_clients 1
i=0 i=0
while [ $i -lt 60 ]; do while [ $i -lt 60 ]; do
if grep -q "@@@ server complete @@@" "$testname.tmux.log"; then if grep -q "@@@ server complete @@@" "$testname.tmux.log"; then