elvish/elvish-stub/test.sh

39 lines
573 B
Bash
Raw Normal View History

2016-02-21 07:28:15 +08:00
#!/bin/sh
fail() {
echo "$*; log left at $log"
exit 1
}
lastLogIs() {
test "$(tail -n1 $log)" = "$*"
}
2016-02-21 07:28:15 +08:00
log=`mktemp elvishXXXXX`
# Start elvish-stub.
elvish-stub > $log &
stub=$!
# Wait for startup message.
for i in `seq 51`; do
2016-02-21 07:56:04 +08:00
test $i == 51 && {
fail "elvish-stub didn't write startup message within 5 seconds"
}
lastLogIs ok && break
sleep 0.1
done
2016-02-21 07:28:15 +08:00
# Send a SIGINT.
kill -2 $stub
ps $stub >/dev/null || {
fail "stub killed by SIGTERM"
}
lastLogIs 2 || {
2016-02-21 07:28:15 +08:00
fail "stub didn't record SIGTERM"
}
# Really kill stub.
kill -9 $stub
rm $log