vero4karu
7/26/2016 - 5:24 PM

Run Django tests and let espeak playout the result

Run Django tests and let espeak playout the result

#/bin/bash

convertsecs() {
 ((h=${1}/3600))
 ((m=(${1}%3600)/60))
 ((s=${1}%60))
 printf "Tests took %02d hours, %02d minutes, %02d seconds...\n" $h $m $s
}

env python manage.py test --settings settings.test_settings $1 2> logs/test_stderr.log

if [ $? -ne 0 ]; then
    cat logs/test_stderr.log
fi

seconds=`grep Ran logs/test_stderr.log | sed -e 's/^Ran\s[[:digit:]]\+\stests\sin\s//' | sed -e 's/\.[[:digit:]]\+s$//'`

echo $(convertsecs $seconds) > result.txt

tail -n1 logs/test_stderr.log | \
    sed -e 's/failures=\([[:digit:]]\+\)/\1 failures/' | \
    sed -e 's/skipped=\([[:digit:]]\+\)/\1 skipped/' | \
    sed -e 's/errors=\([[:digit:]]\+\)/\1 errors/' | \
    sed -e 's/^OK/All tests successful /' >> result.txt && \
    espeak -ven+f2 -s 180 -w result.wav -f result.txt && \
    vlc --play-and-exit --quiet --intf dummy vcd:// result.wav && \
    rm result.txt result.wav