b742e958b6
Closes #690.
43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
#
|
|
# Harness script for Mosh tests, server side. Runs test script and
|
|
# then captures screen with `tmux capture-pane`. Captures exitstatus
|
|
# of both and returns appropriate errors.
|
|
#
|
|
export MOSH_SERVER_PID=$PPID
|
|
|
|
if [ $# -lt 2 ]; then
|
|
printf "not enough args\n" >&2
|
|
exit 99
|
|
fi
|
|
testname=$1
|
|
shift
|
|
rm -f $testname.capture $testname.exitstatus
|
|
trap ":" TERM HUP QUIT # If the session closes on us, let the test we're running drive.
|
|
trap 'rv=$?; echo $rv > $testname.exitstatus; exit $rv' EXIT
|
|
# check for tmux
|
|
if [ -z "$TMUX_PANE" ]; then
|
|
printf "not running under tmux\n" >&2
|
|
exit 99
|
|
fi
|
|
# run harnessed command
|
|
eval "$@"
|
|
testret=$?
|
|
# Wait a bit for tmux screen to become up to date.
|
|
sleep 1
|
|
# capture screen
|
|
if ! tmux capture-pane -et $TMUX_PANE; then
|
|
printf "tmux capture-pane failed, erroring test\n" >&2
|
|
exit 99
|
|
fi
|
|
if ! tmux save-buffer $testname.capture; then
|
|
printf "tmux save-buffer failed, erroring test\n" >&2
|
|
exit 99
|
|
fi
|
|
# return useful exitstatus from harnessed command
|
|
if [ $testret -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
exit 0
|