aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2016-05-15 17:53:02 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2016-05-15 17:53:02 +1200
commitf7a663c322fde4b03babd9ca16bcd704c74a134f (patch)
tree448e7177f815fdf9e1af96ca74ba9953a05ac231
parentd732e377e81ba1c49d1e4f537066cd989feebca2 (diff)
downloadpgm-interlace-f7a663c322fde4b03babd9ca16bcd704c74a134f.tar.xz
Change test.sh pass/fail logic
-rwxr-xr-xtest/test.sh58
1 files changed, 43 insertions, 15 deletions
diff --git a/test/test.sh b/test/test.sh
index 0ba6164..6d51639 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -5,32 +5,60 @@ fail()
echo -e '[\e[1;31mFAIL\e[0m] '$i
}
+
+xfail()
+{
+ echo -e '[\e[1;35mXFAIL\e[0m] '$i
+}
+
pass()
{
echo -e '[\e[0;32mPASS\e[0m] '$i
}
-
#########################
# tests expected to pass
cd $(dirname $0)
export EXECUTABLE="$PWD/../pgm-interlace"
-
-
-pushd pass >/dev/null
-for i in *.sh ; do
- name=${i/.sh/}
+for i in {pass,error,xfail}/*.sh ; do
+ test_type=$(dirname $i)
+ pushd $test_type > /dev/null
+ name=$(basename ${i/.sh/})
expected="$name.pgm.expected"
out="$name.pgm.out"
- ./$i
- diff $expected $out
- if [ $? -ne 0 ] ; then
- fail
- exit 1
- fi
- pass
- rm $out
+ ./$(basename $i) 2> $name.stderr.log
+ [ -f $expected ] && diff $expected $out
+ result=$?
+ case $test_type in
+ pass)
+ if [ $result -eq 0 ] ; then
+ pass
+ else
+ fail
+ fi
+ ;;
+ error)
+ if [ $result -ne 0 ] ; then
+ pass
+ else
+ fail
+ fi
+ ;;
+ xfail)
+ if [ $result -ne 0 ] ; then
+ xfail
+ else
+ fail
+ fi
+ ;;
+ *)
+ echo Unexpected test type "$test_type", bailing
+ exit 1
+ ;;
+ esac
+
+ rm -f $out $name.stderr.log
+ popd > /dev/null
done
-popd > /dev/null