From: David Levine Date: Sat, 18 Feb 2012 17:21:28 +0000 (-0600) Subject: Have each test clean up after itself if it completes successfully. X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=c6bf562d9e823f02fb4a9e6dfb89bf93a0e9d0ab;p=mmh Have each test clean up after itself if it completes successfully. --- diff --git a/test/inc/test-eom-align b/test/inc/test-eom-align index 2afa100..48c3c01 100755 --- a/test/inc/test-eom-align +++ b/test/inc/test-eom-align @@ -29,7 +29,7 @@ fi # minor corruptions such as line ending changes could # render the tests useless.) (cd "$THISDIR" && output_md5 *.txt > "$MH_TEST_DIR/inctest.md5sums") -diff -u "$THISDIR/md5sums" "$MH_TEST_DIR/inctest.md5sums" +check "$THISDIR/md5sums" "$MH_TEST_DIR/inctest.md5sums" 'keep first' FILLER="$THISDIR/filler.txt" FROMLINE="$THISDIR/fromline.txt" @@ -96,10 +96,12 @@ do_one_test_A () { $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox" # We know the messages should be 11 and 12 in inbox # Now get the bodies back out. - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$MH_TEST_DIR/eom-align.inbox.body1" - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/12" > "$MH_TEST_DIR/eom-align.inbox.body2" - diff -u "$MH_TEST_DIR/eom-align.mbox.body" "$MH_TEST_DIR/eom-align.inbox.body1" - diff -u "$FILLER" "$MH_TEST_DIR/eom-align.inbox.body2" + body1="$MH_TEST_DIR/eom-align.inbox.body1" + body2="$MH_TEST_DIR/eom-align.inbox.body2" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$body1" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/12" > "$body2" + check "$MH_TEST_DIR/eom-align.mbox.body" "$body1" 'keep first' + check "$FILLER" "$body2" 'keep first' rmm 11 12 } @@ -110,12 +112,12 @@ do_one_test_B () { makembox_B "$MH_TEST_DIR/eom-align.mbox" $STDIO_BUFSZ $VALGRIND inc -silent -file "$MH_TEST_DIR/eom-align.mbox" # We know the message should be 11 in the inbox - sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$MH_TEST_DIR/eom-align.inbox.body1" - diff -u "$MH_TEST_DIR/eom-align.mbox.body" "$MH_TEST_DIR/eom-align.inbox.body1" + body1="$MH_TEST_DIR/eom-align.inbox.body1" + sed -e '1,/^$/d' "$MH_TEST_DIR/Mail/inbox/11" > "$body1" + check "$MH_TEST_DIR/eom-align.mbox.body" "$body1" 'keep first' rmm 11 } - # Cover a decent range around the stdio buffer size to make sure we catch # any corner cases whether they relate to total message size equal to # buffer size or to body size equal to buffer size. @@ -130,3 +132,8 @@ while test $i -le $FINISH; do i=$(expr $i + 1) done progress_done + +test ${failed:-0} -eq 0 && \ +rm "$MH_TEST_DIR/eom-align.mbox" "$MH_TEST_DIR/eom-align.mbox.body" + +exit $failed diff --git a/test/manpages/test-manpages b/test/manpages/test-manpages index fb86c73..4865985 100755 --- a/test/manpages/test-manpages +++ b/test/manpages/test-manpages @@ -35,4 +35,6 @@ for manpage in man?/*.?; do groff -Tutf8 -mandoc -wmac "$manpage" > /dev/null 2>>"$actual" done -diff -u "$expected" "$actual" +check "$expected" "$actual" + +exit $failed diff --git a/test/mhbuild/test-forw b/test/mhbuild/test-forw index 22f32df..448a17c 100755 --- a/test/mhbuild/test-forw +++ b/test/mhbuild/test-forw @@ -32,9 +32,10 @@ mungedraft() { sed 's/\(Content-ID:\) <[^>][^>]*>/\1 /' $draft > $actual } -draft=$MH_TEST_DIR/$$.draft -expected=$MH_TEST_DIR/$$.expected -actual=$MH_TEST_DIR/$$.actual +draft="$MH_TEST_DIR/$$.draft" +draftorig="$MH_TEST_DIR/,$$.draft.orig" +expected="$MH_TEST_DIR/$$.expected" +actual="$MH_TEST_DIR/$$.actual" # check mhbuild cat > $expected < $expected < $actual 2>&1 -diff -u $expected $actual +check "$expected" "$actual" + +exit $failed + diff --git a/test/mhshow/test-qp b/test/mhshow/test-qp index 3d4beb8..12f7f83 100755 --- a/test/mhshow/test-qp +++ b/test/mhshow/test-qp @@ -69,4 +69,6 @@ just a newline = ^H (backspace) character, probably erased = in diff output EOF mhshow -nopause $msgnum > $actual 2>&1 -diff -u $expected $actual +check "$expected" "$actual" + +exit $failed diff --git a/test/mhshow/test-subpart b/test/mhshow/test-subpart index 6396f62..c2a7262 100755 --- a/test/mhshow/test-subpart +++ b/test/mhshow/test-subpart @@ -57,4 +57,6 @@ EOF # check it mhshow -part 1.1 -form mhl.null -nopause $msgnum > $actual 2>&1 -diff -u $expected $actual && rm -f $expected $actual +check "$expected" "$actual" + +exit $failed diff --git a/test/pick/test-stderr b/test/pick/test-stderr index e45e13d..0cafe7f 100755 --- a/test/pick/test-stderr +++ b/test/pick/test-stderr @@ -29,5 +29,5 @@ EOF cat /dev/null > $expected_out pick -a > $actual_out 2> $actual_err -diff -u $expected_err $actual_err || exit 1 -diff -u $expected_out $actual_out || exit 1 +check "$expected_err" "$actual_err" +check "$expected_out" "$actual_out" diff --git a/test/repl/test-if-str b/test/repl/test-if-str index 8456df8..327f1c9 100755 --- a/test/repl/test-if-str +++ b/test/repl/test-if-str @@ -42,4 +42,8 @@ EOF repl -editor true -format -form $form -group -nocc me -nowhatnowproc 1 || exit 1 -diff -u $expected $actual +check "$expected" "$actual" + +test ${failed:-0} -eq 0 && rm "$form" + +exit $failed diff --git a/test/scan/test-scan b/test/scan/test-scan index c0408f4..1c6d949 100755 --- a/test/scan/test-scan +++ b/test/scan/test-scan @@ -32,4 +32,6 @@ EOF scan -width 80 +inbox > $actual || exit 1 -diff -u $expected $actual +check "$expected" "$actual" + +exit $failed diff --git a/test/whatnow/test-attach-detach b/test/whatnow/test-attach-detach index a297273..3ac5f3b 100755 --- a/test/whatnow/test-attach-detach +++ b/test/whatnow/test-attach-detach @@ -6,6 +6,8 @@ # ###################################################### +set -e + if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR @@ -15,11 +17,10 @@ fi setup_test -set -e - cd "$MH_TEST_DIR" -rm -f "baz's boz" -touch "baz's boz" +testname="baz's boz" +testname_quoted="baz\'s\ boz" +touch "$testname" # whatnow's attach stuff needs a draft to work on cp "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/draft" @@ -32,16 +33,22 @@ rm -f $expected $expectederr $actual $actualerr touch $expected $expectederr $actual $actualerr cat > $expected <> $actualerr >> $actual +echo "attach $testname_quoted" | \ + whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual echo "alist" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual -echo "detach baz\\'s\\ boz" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual +echo "detach $testname_quoted" | \ + whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual echo "alist" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual set -e -diff -u $expectederr $actualerr || exit 1 -diff -u $expected $actual +check "$expectederr" "$actualerr" +check "$expected" "$actual" + +test ${failed:-0} -eq 0 && rm "$testname" + +exit $failed diff --git a/test/whatnow/test-cd b/test/whatnow/test-cd index d8feb34..1ff5d96 100755 --- a/test/whatnow/test-cd +++ b/test/whatnow/test-cd @@ -6,6 +6,8 @@ # ###################################################### +set -e + if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR @@ -15,13 +17,10 @@ fi setup_test -set -e SPDIR="$MH_TEST_DIR/foo's bar" rm -rf "$SPDIR" mkdir "$SPDIR" -cd "$SPDIR" -touch baz boz -cd +(cd "$SPDIR" && touch baz boz) expectederr=$MH_TEST_DIR/$$.expectederr actualerr=$MH_TEST_DIR/$$.actualerr @@ -37,7 +36,12 @@ EOF # ||true to ignore whatnow's exit status # watch the quoting -- shell and printf and then the shell run inside whatnow -printf "cd $MH_TEST_DIR/foo\\\\'s\\\\ bar\npwd\n" | whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true +printf "cd $MH_TEST_DIR/foo\\\\'s\\\\ bar\npwd\n" | \ + whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true + +check "$expectederr" "$actualerr" +check "$expected" "$actual" + +test ${failed:-0} -eq 0 && rm -r "$SPDIR" -diff -u $expectederr $actualerr || exit 1 -diff -u $expected $actual +exit $failed diff --git a/test/whatnow/test-ls b/test/whatnow/test-ls index e3571ac..f212e41 100755 --- a/test/whatnow/test-ls +++ b/test/whatnow/test-ls @@ -6,6 +6,8 @@ # ###################################################### +set -e + if test -z "${MH_OBJ_DIR}"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR @@ -15,7 +17,6 @@ fi setup_test -set -e SPDIR="$MH_TEST_DIR/foo's bar" rm -rf "$SPDIR" mkdir "$SPDIR" @@ -38,5 +39,9 @@ EOF # NB use of sort as the order of output of ls is not guaranteed echo 'ls' | whatnow -noedit -prompt '' 2> "$actualerr" | sort > "$actual" -diff -u $expectederr $actualerr || exit 1 -diff -u $expected $actual +check "$expectederr" "$actualerr" +check "$expected" "$actual" + +test ${failed:-0} -eq 0 && rm -r "$SPDIR" + +exit $failed