aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2016-03-13 13:23:13 +1300
committerDavid Phillips <dbphillipsnz@gmail.com>2016-03-13 13:23:13 +1300
commitb9003460bf7abb7f35aafa9c6eae1915e25a3ac1 (patch)
tree4291c4d9981f6b21a3d395a85ef72ab0f3f937ed
parent4ad1f662ff407644e33be1101b4b17df01c64fd0 (diff)
downloadcue-bin-split-b9003460bf7abb7f35aafa9c6eae1915e25a3ac1.tar.xz
Tidy main test script
-rwxr-xr-xtest/run-tests.sh32
1 files changed, 15 insertions, 17 deletions
diff --git a/test/run-tests.sh b/test/run-tests.sh
index 3b82bc2..c6a7cce 100755
--- a/test/run-tests.sh
+++ b/test/run-tests.sh
@@ -1,7 +1,5 @@
#!/bin/sh
-err_file="stderr.tmp"
-out_file="stdout.tmp"
EXECUTABLE="$PWD/../cue-bin-split"
fail()
@@ -10,29 +8,29 @@ fail()
exit 1
}
+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
+ fail "$1 didn't match expected"
+ fi
+ fi
+}
+
for i in *.test ; do
pushd ${i} >/dev/null
- ( . ./run.sh ) 2>${err_file} >${out_file}
+ ( . ./run.sh ) 2>stderr.tmp >stdout.tmp
if [ $? -ne 0 ] ; then
fail "script had non-zero return code"
fi
- if [ -f stderr.expected ] ; then
- diff stderr.expected stderr.tmp
- if [ $? -ne 0 ] ; then
- fail "stderr didn't match expected"
- fi
- fi
-
- if [ -f stdout.expected ] ; then
- diff stdout.expected stdout.tmp
- if [ $? -ne 0 ] ; then
- fail "stdout didn't match expected"
- fi
- fi
+ check_expected stdout
+ check_expected stderr
echo "[PASS] $i"
- rm ${err_file} ${out_file}
+ rm std{err,out}.tmp
popd >/dev/null
done