Merge pull request #1115 from psychon/timeouts

Don't use sleep to implement timeouts in the test runner
This commit is contained in:
Daniel Hahler 2016-09-25 13:00:31 +02:00 committed by GitHub
commit 8dc98e8c51
1 changed files with 13 additions and 9 deletions

View File

@ -182,7 +182,8 @@ fi
start_awesome() { start_awesome() {
export DISPLAY="$D" export DISPLAY="$D"
cd $build_dir cd $build_dir
DISPLAY="$D" "$AWESOME" -c "$RC_FILE" $AWESOME_OPTIONS > $awesome_log 2>&1 & # Kill awesome after $timeout_stale seconds (e.g. for errors during test setup).
DISPLAY="$D" timeout $timeout_stale "$AWESOME" -c "$RC_FILE" $AWESOME_OPTIONS > $awesome_log 2>&1 &
awesome_pid=$! awesome_pid=$!
cd - >/dev/null cd - >/dev/null
@ -209,20 +210,23 @@ for f in $tests; do
# Send the test file to awesome. # Send the test file to awesome.
cat $f | DISPLAY=$D "$AWESOME_CLIENT" 2>&1 cat $f | DISPLAY=$D "$AWESOME_CLIENT" 2>&1
# Kill awesome after 1 minute (e.g. with errors during test setup).
(sleep $timeout_stale
if [ "$(ps -o comm= $awesome_pid)" = "${AWESOME##*/}" ]; then
echo "Killing (stale?!) awesome (PID $awesome_pid) after $timeout_stale seconds."
kill $awesome_pid
fi) &
# Tail the log and quit, when awesome quits. # Tail the log and quit, when awesome quits.
tail -n 100000 -f --pid $awesome_pid $awesome_log tail -n 100000 -f --pid $awesome_pid $awesome_log
set +e
wait $awesome_pid
code=$?
set -e
case $code in
0) ;;
124) echo "Awesome was killed due to timeout after $timeout_stale seconds" ;;
*) echo "Awesome exited with status code $code" ;;
esac
if ! grep -q -E '^Test finished successfully$' $awesome_log || if ! grep -q -E '^Test finished successfully$' $awesome_log ||
grep -q -E '[Ee]rror|assertion failed' $awesome_log; then grep -q -E '[Ee]rror|assertion failed' $awesome_log; then
echo "===> ERROR running $f! <===" echo "===> ERROR running $f! <==="
grep --color -o --binary-files=text -E '.*[Ee]rror.*|.*assertion failed.*' $awesome_log grep --color -o --binary-files=text -E '.*[Ee]rror.*|.*assertion failed.*' $awesome_log || true
errors=$(expr $errors + 1) errors=$(expr $errors + 1)
fi fi
done done