#! /bin/bash #************************************************************************* # "run-tests" is free software: you can redistribute it and/or modify * # it under the terms of the GNU Affero Public License as published by * # the Free Software Foundation, either version 3 of the License, or * # (at your option) any later version. * # * # "run-tests" is distributed in the hope that it will be useful, * # but WITHOUT ANY WARRANTY; without even the implied warranty of * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * # GNU Affero Public License for more details. * # * # You should have received a copy of the GNU Affero Public License * # along with Edward. If not, see . * # * # Copyright (C) 2015 Andrew Engelbrecht (AGPLv3+) * #************************************************************************* NUM_TESTS=1 G_HOME=./tests/testgnupghome function _main { 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