Use a more robust way to wait for elvish-stub's startup message.

This commit is contained in:
Qi Xiao 2016-02-21 00:52:35 +01:00
parent 830441ca22
commit d96b50240d

View File

@ -4,25 +4,31 @@ fail() {
exit 1
}
lastLogIs() {
test "$(tail -n1 $log)" = "$*"
}
log=`mktemp elvishXXXXX`
# Start elvish-stub.
elvish-stub > $log &
stub=$!
sleep 0.1
# Wait for startup message.
test `tail -n1 $log` == ok || {
fail "no startup message or startup too slow"
}
for i in `seq 51`; do
test i == 51 && {
fail "elvish-stub didn't write startup message within 5 seconds"
}
lastLogIs ok && break
sleep 0.1
done
# Send a SIGINT.
kill -2 $stub
ps $stub >/dev/null || {
fail "stub killed by SIGTERM"
}
test `tail -n1 $log` == 2 || {
lastLogIs 2 || {
fail "stub didn't record SIGTERM"
}