From 6db23c03b5dbc5ba60998527c1cd62f13466a4c7 Mon Sep 17 00:00:00 2001 From: Daniel Aarno Date: Sat, 28 Jul 2018 18:09:56 +0100 Subject: [PATCH] Break out some common test code to a separate file. Next step to refactor remaining tests. --- tests/simple-test.sh | 19 +++++++++++++++++++ tests/test1.sh | 10 +--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100755 tests/simple-test.sh diff --git a/tests/simple-test.sh b/tests/simple-test.sh new file mode 100755 index 0000000..89545ef --- /dev/null +++ b/tests/simple-test.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ -z "$srcdir" ]; then + srcdir=`dirname $0` +fi + +TEST_RESULT=$srcdir/$1 +shift + +../examples/"$@" 2>&1 | tee tmp.out + +if cmp -s tmp.out $TEST_RESULT.out; then + echo "OK" + exit 0 +else + echo "FAIL" + diff tmp.out $TEST_RESULT.out + exit 1 +fi diff --git a/tests/test1.sh b/tests/test1.sh index f59f014..5805886 100755 --- a/tests/test1.sh +++ b/tests/test1.sh @@ -1,11 +1,3 @@ #!/bin/sh -# success -../examples/test1 -r -n mike > tmp.out 2>&1 - -if cmp -s tmp.out $srcdir/test1.out; then - exit 0 -else - exit 1 -fi - +./simple-test.sh test1 `basename $0 .sh` -r -n mike