From a3c531c360fa93e36b862087450f34129b6f49cc Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Mon, 20 Jul 2015 15:43:27 -0400 Subject: [PATCH] partially generalized the testing suite --- run-tests | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/run-tests b/run-tests index 48570f1..a16fa00 100755 --- a/run-tests +++ b/run-tests @@ -17,12 +17,50 @@ # Copyright (C) 2015 Andrew Engelbrecht (AGPLv3+) * #************************************************************************* +NUM_TESTS=1 G_HOME=./tests/testgnupghome -OUT_DIFF_1="$(time ./edward < ./tests/test1.eml | GNUPGHOME="$G_HOME" gpg 2> /dev/null | ./tests/flatten-mime | diff -Z -u ./tests/out1.txt - )" +function _main { -if [ -n "$OUT_DIFF_1" ] ; then - echo "*** test 1 failed! difference:" >&2 - echo "$OUT_DIFF_1" >&2 -fi + COUNT=$1 + + ERROR_COUNT="0" + for i in $(seq "$COUNT") ; do + + TEST_INPUT="./tests/test$i.eml" + TEST_OUTPUT="./tests/out$i.txt" + + _exec_compare "$TEST_INPUT" "$TEST_OUTPUT" + ERROR=$? + + ERROR_COUNT="$(expr "$ERROR_COUNT" + "$ERROR")" + done + + if [ "$ERROR_COUNT" != "0" ] ; then + echo "*** Failed test count: $ERROR_COUNT" >&2 + exit 1 + fi + + exit 0 + +} + +function _exec_compare { + + TEST_INPUT="$1" + TEST_OUTPUT="$2" + + OUT_DIFF="$(time ./edward < "$TEST_INPUT" | GNUPGHOME="$G_HOME" gpg 2> /dev/null | ./tests/flatten-mime | diff -Z -u "$TEST_OUTPUT" - )" + + if [ -n "$OUT_DIFF" ] ; then + echo "*** test 1 failed! difference:" >&2 + echo "$OUT_DIFF" >&2 + + return 1 + fi + + return 0 +} + +_main $NUM_TESTS -- 2.25.1