From d34c4fb99a770add02347b29e7c0bb9a46ec7dc1 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Tue, 12 Sep 2017 21:47:29 +1200 Subject: Clean up test runner script --- test/run-tests.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/run-tests.sh b/test/run-tests.sh index f24ac73..b7f7856 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -3,39 +3,37 @@ fail() { - echo -e '[\e[1;31mFAIL\e[0m] '$i: $@ + echo -e '[\e[1;31mFAIL\e[0m] '"$i:" "$@" exit 1 } pass() { - echo -e '[\e[0;32mPASS\e[0m] '$i + echo -e '[\e[0;32mPASS\e[0m] '"$i" } check_expected() { - [ -z $1 ] && echo WARN: check_expected called with no argument - if [ -f $1.expected ] ; then - diff $1.expected $1.tmp >/dev/null - if [ $? -ne 0 ] ; then + [ -z "$1" ] && echo WARN: check_expected called with no argument + if [ -f "$1.expected" ] ; then + if ! diff "$1.expected" "$1.tmp" >/dev/null; then fail "$1 didn't match expected" fi fi } -pushd $(dirname $0) >/dev/null -EXECUTABLE="../../sand-leek" +pushd "$(dirname "$0")" >/dev/null +export EXECUTABLE="../../sand-leek" for i in *.test ; do - pushd ${i} >/dev/null - ( . ./run.sh ) 2>stderr.tmp >stdout.tmp - if [ $? -ne 0 ] ; then + pushd "${i}" >/dev/null + if ! ( . ./run.sh ) 2>stderr.tmp >stdout.tmp; then fail "script had non-zero return code" fi check_expected stdout check_expected stderr - pass $i + pass "$i" rm std{err,out}.tmp popd >/dev/null -- cgit v1.1