From: David Levine Date: Mon, 2 Jul 2012 00:20:22 +0000 (-0500) Subject: Added test-dp, test-fmtdump, test-prompter, test-rcvstore, X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=1ae96ed565c1bb0ae054f81b47bf960d2b62e658;p=mmh Added test-dp, test-fmtdump, test-prompter, test-rcvstore, test-rcvpack, and test-rcvdist. --- diff --git a/Makefile.am b/Makefile.am index 1f83352..0c01502 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,9 +47,9 @@ TESTS = test/ali/test-ali \ test/burst/test-burst \ test/comp/test-comp-format \ test/folder/test-create test/folder/test-sortm \ - test/folder/test-total test/format/test-localmbox \ - test/format/test-myname test/format/test-myhost \ - test/format/test-mymbox \ + test/folder/test-total test/format/test-dp test/format/test-fmtdump \ + test/format/test-localmbox test/format/test-myname \ + test/format/test-myhost test/format/test-mymbox \ test/forw/test-forw-digest \ test/forw/test-forw-format \ test/inc/test-deb359167 test/inc/test-eom-align \ @@ -65,6 +65,8 @@ TESTS = test/ali/test-ali \ test/post/test-post-dcc test/post/test-post-fcc \ test/post/test-post-multifrom test/post/test-post-envelope \ test/post/test-post-group \ + test/prompter/test-prompter \ + test/rcv/test-rcvdist test/rcv/test-rcvpack test/rcv/test-rcvstore \ test/refile/test-refile \ test/repl/test-if-str test/repl/test-trailing-newline \ test/repl/test-multicomp test/repl/test-repl \ diff --git a/test/format/test-dp b/test/format/test-dp new file mode 100755 index 0000000..023d579 --- /dev/null +++ b/test/format/test-dp @@ -0,0 +1,115 @@ +#!/bin/sh +###################################################### +# +# Test dp +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +# Use proper program, likely not the first one on PATH. +dp="${MH_LIB_DIR}/dp" + +expected="$MH_TEST_DIR/$$.expected" +expected_err="$MH_TEST_DIR/$$.expected_err" +actual="$MH_TEST_DIR/$$.actual" +actual_err="$MH_TEST_DIR/$$.actual_err" + + +# check -help +cat >"$expected" <"$actual" 2>&1 +check "$expected" "$actual" + +# check -version +case `$dp -v` in + dp\ --*) ;; + * ) printf "$0: dp -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "$dp -nonexistent" 'dp: -nonexistent unknown' + +# check with no switches +run_test "$dp" 'dp: usage: dp [switches] dates ...' + +# check with one valid date +cat >"$expected" < "$actual" 2>&1 +check "$expected" "$actual" + +# check with two valid dates +cat >"$expected" < "$actual" 2>&1 +check "$expected" "$actual" + +# check with invalid date +cat >"$expected" <"$expected_err" < "$actual" 2> "$actual_err" +check "$expected" "$actual" +check "$expected_err" "$actual_err" + +# check -form +form="${MH_TEST_DIR}/Mail/dp-form" +cat >"$form" <<'EOF' +%(day{text}) +EOF + +cat >"$expected" <$actual 2>&1 +check $expected $actual +rm -f "$form" + +# check -format +cat >"$expected" <$actual 2>&1 +check $expected $actual + +# check -width +cat >"$expected" < "$actual" 2>&1 +check "$expected" "$actual" + + +exit ${failed:-0} diff --git a/test/format/test-fmtdump b/test/format/test-fmtdump new file mode 100755 index 0000000..44380ba --- /dev/null +++ b/test/format/test-fmtdump @@ -0,0 +1,129 @@ +#!/bin/sh +###################################################### +# +# Test fmtdump +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +# Use proper program, likely not the first one on PATH. +fmtdump="${MH_LIB_DIR}/fmtdump" + +expected=$MH_TEST_DIR/$$.expected +expected_err=$MH_TEST_DIR/$$.expected_err +actual=$MH_TEST_DIR/$$.actual +actual_err=$MH_TEST_DIR/$$.actual_err + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `$fmtdump -v` in + fmtdump\ --*) ;; + * ) printf "$0: fmtdump -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "$fmtdump -nonexistent" 'fmtdump: -nonexistent unknown' + +# check with no switches +cat >$expected < + LV_MON, c_name "date", c_type + NUMF, width 2, fill '0' + CHAR '/' + PARSEDATE, c_name "date", c_type + LV_MDAY, c_name "date", c_type + NUMF, width 2, fill '0' + LS_COMP, comp "date", c_type + IF_S continue else goto L6 + CHAR ' ' + GOTO L7 +L6: CHAR '*' +L7: MYMBOX, c_name "from", c_type + LV_COMPFLAG, comp "from", c_type + IF_V_NE 0 continue else goto L8 + LS_COMP, comp "to", c_type + IF_S continue else goto L8 + LIT "To:" + PARSEADDR, c_name "to", c_type + LS_FRIENDLY, c_name "to", c_type + FT_LS_DECODE + STRF, width 14, fill ' ' +L8: IF_V_EQ 0 continue else goto L9 + PARSEADDR, c_name "from", c_type + LS_FRIENDLY, c_name "from", c_type + FT_LS_DECODE + STRF, width 17, fill ' ' +L9: LIT " " + LS_COMP, comp "subject" + FT_LS_DECODE + STR + LS_COMP, comp "body" + IF_S continue else goto L10 + LIT "<<" + COMP, comp "body" + LIT ">>" +L10: CHAR '\n' + DONE +EOF + +$fmtdump >$actual 2>&1 +check $expected $actual 'keep first' + +# check -form +$fmtdump -form "$MH_TEST_DIR/Mail/scan.default" >$actual 2>&1 +check $expected $actual + +# check -format +cat >$expected <' >$actual 2>&1 +check $expected $actual + + +exit ${failed:-0} diff --git a/test/prompter/test-prompter b/test/prompter/test-prompter new file mode 100755 index 0000000..4cf8539 --- /dev/null +++ b/test/prompter/test-prompter @@ -0,0 +1,235 @@ +#!/bin/sh +###################################################### +# +# Test prompter +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +expected=$MH_TEST_DIR/$$.expected +expected_err=$MH_TEST_DIR/$$.expected_err +actual=$MH_TEST_DIR/$$.actual +actual_err=$MH_TEST_DIR/$$.actual_err + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `prompter -v` in + prompter\ --*) ;; + * ) printf "$0: prompter -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test 'prompter -nonexistent' 'prompter: -nonexistent unknown' + + +# check with no switches +run_test 'prompter' 'prompter: usage: prompter [switches] file' + +# check with file +cat >$expected <$MH_TEST_DIR/prompter-file < /dev/null + +check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' + +# check -doteof +cat >$MH_TEST_DIR/prompter-file < /dev/null + +check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' + +# check -nodoteof +cat >$MH_TEST_DIR/prompter-file < /dev/null + +check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first' + +# check -noprepend +cat >$MH_TEST_DIR/prompter-file <> "$expected" + +printf "recipient@example.com\ncc@example.com\n+outbox\nappendage\n" | \ + prompter -noprepend $MH_TEST_DIR/prompter-file > /dev/null + +check "$expected" "$MH_TEST_DIR/prompter-file" + +# check -prepend +cat >$MH_TEST_DIR/prompter-file <$expected < /dev/null + +check "$MH_TEST_DIR/prompter-file" "$expected" 'keep first' + +# check -rapid +cat >$expected < "$actual" < /dev/null + +check "$expected" "$actual" + +# check -norapid +cat >$expected < "$actual" < /dev/null + +check "$expected" "$actual" + +# check -erase and -kill. We can't test their effects because they +# only affect the terminal and this test execution might not be +# connected to one. So we can just check that the respective options +# were set. +cat >$expected < "$actual" + +check "$expected" "$actual" + +# check -body. It's undocumented but the default, so make sure that +# it reverses the effect of -nobody. +cat >$expected < "$actual" < /dev/null + +check "$expected" "$actual" + +# check -nobody. It's undocumented but looks like it removes the body. +cat >$expected < /dev/null + +check "$expected" "$MH_TEST_DIR/prompter-file" + + +exit ${failed:-0} diff --git a/test/rcv/test-rcvdist b/test/rcv/test-rcvdist new file mode 100755 index 0000000..1f22754 --- /dev/null +++ b/test/rcv/test-rcvdist @@ -0,0 +1,101 @@ +#!/bin/sh +###################################################### +# +# Test rcvdist +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +# Use proper program, likely not the first one on PATH. +rcvdist="${MH_LIB_DIR}/rcvdist" + +expected=$MH_TEST_DIR/$$.expected +actual=$MH_TEST_DIR/$$.actual + + +# check -help +cat >$expected <"$actual" 2>&1 +check "$expected" "$actual" + +# check -version +case `$rcvdist -v` in + rcvdist\ --*) ;; + * ) printf "$0: rcvdist -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "$rcvdist -nonexistent" \ + 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...' + +# check with no switches +run_test "$rcvdist" \ + 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...' + +# check with address +# Replace post: +cat >"$MH_TEST_DIR/Mail/notpost" < "${MH}-new" +printf "postproc: $MH_TEST_DIR/Mail/notpost\n" >>"${MH}-new" +mv -f "${MH}-new" "$MH" + +#### An extra space gets inserted between each header field name +#### and body. That probably should be fixed. +cat > "$expected" < +To: Some User +Date: Fri, 29 Sep 2006 00:00:00 +Subject: Testing message 1 +Resent-To: recipient@example.com + +This is message number 1 +EOF + +$rcvdist recipient@example.com < "$MH_TEST_DIR/Mail/inbox/1" +check "$expected" "$actual" + +# check -form +cat > "$expected" < +To: Some User +Date: Fri, 29 Sep 2006 00:00:00 +Subject: Testing message 1 +Resent-To: recipient@example.com +Resent-From: Some User + +This is message number 1 +EOF + +cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF' +%(lit)%(formataddr{addresses})\ +%<(nonnull)%(void(width))%(putaddr Resent-To:)%> +%(lit)%(formataddr{to})\ +%<(nonnull)%(void(width))%(putaddr Resent-From:)\n%> +EOF + +$rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com < \ + "$MH_TEST_DIR/Mail/inbox/1" +check "$expected" "$actual" + +exit ${failed:-0} diff --git a/test/rcv/test-rcvpack b/test/rcv/test-rcvpack new file mode 100755 index 0000000..9433a37 --- /dev/null +++ b/test/rcv/test-rcvpack @@ -0,0 +1,79 @@ +#!/bin/sh +###################################################### +# +# Test rcvpack +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +# Use proper program, likely not the first one on PATH. +rcvpack="${MH_LIB_DIR}/rcvpack" + +expected=$MH_TEST_DIR/$$.expected +expected_err=$MH_TEST_DIR/$$.expected_err +actual=$MH_TEST_DIR/$$.actual +actual_err=$MH_TEST_DIR/$$.actual_err + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `$rcvpack -v` in + rcvpack\ --*) ;; + * ) printf "$0: rcvpack -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "$rcvpack -nonexistent" 'rcvpack: -nonexistent unknown' + +# check with no switches +run_test "$rcvpack" 'rcvpack: rcvpack [switches] file' + +# check mbox creation +$rcvpack <${MH_TEST_DIR}/Mail/inbox/1 ${MH_TEST_DIR}/Mail/mbox +inc -file ${MH_TEST_DIR}/Mail/mbox -silent +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -mbox +$rcvpack -mmdf -mbox <${MH_TEST_DIR}/Mail/inbox/1 ${MH_TEST_DIR}/Mail/mbox2 +check "${MH_TEST_DIR}/Mail/mbox" "${MH_TEST_DIR}/Mail/mbox2" 'keep first' + +# check append to existing mbox file +$rcvpack <${MH_TEST_DIR}/Mail/inbox/2 ${MH_TEST_DIR}/Mail/mbox +inc -file ${MH_TEST_DIR}/Mail/mbox -silent +check "${MH_TEST_DIR}/Mail/inbox/2" "${MH_TEST_DIR}/Mail/inbox/12" 'keep first' + +# check -mmdf +$rcvpack -mmdf <${MH_TEST_DIR}/Mail/inbox/3 ${MH_TEST_DIR}/Mail/mmdf +inc -file ${MH_TEST_DIR}/Mail/mmdf -silent +check "${MH_TEST_DIR}/Mail/inbox/3" "${MH_TEST_DIR}/Mail/inbox/12" 'keep first' + +# check append to existing mmdf file +$rcvpack -mmdf <${MH_TEST_DIR}/Mail/inbox/4 ${MH_TEST_DIR}/Mail/mmdf +inc -file ${MH_TEST_DIR}/Mail/mmdf -silent +check "${MH_TEST_DIR}/Mail/inbox/4" "${MH_TEST_DIR}/Mail/inbox/13" 'keep first' + + +exit ${failed:-0} diff --git a/test/rcv/test-rcvstore b/test/rcv/test-rcvstore new file mode 100755 index 0000000..0493bc2 --- /dev/null +++ b/test/rcv/test-rcvstore @@ -0,0 +1,205 @@ +#!/bin/sh +###################################################### +# +# Test rcvstore +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +# Use proper program, likely not the first one on PATH. +rcvstore="${MH_LIB_DIR}/rcvstore" + +expected=$MH_TEST_DIR/$$.expected +expected_err=$MH_TEST_DIR/$$.expected_err +actual=$MH_TEST_DIR/$$.actual +actual_err=$MH_TEST_DIR/$$.actual_err + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `$rcvstore -v` in + rcvstore\ --*) ;; + * ) printf "$0: rcvstore -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "$rcvstore -nonexistent" 'rcvstore: -nonexistent unknown' + +# check with no switches and zero-length input message +cat >$expected <$actual 2>&1 +check $expected $actual + +# check with no switches +cat >$expected <$actual 2>&1 +check $expected $actual 'keep first' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check + of existing folder +$rcvstore +inbox <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check + of new folder +$rcvstore +newfolder <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \ + 'keep first' +rmdir "${MH_TEST_DIR}/Mail/newfolder" + +# check -nocreate +cat >$expected_err <$actual \ + 2>$actual_err +set -e +check $expected $actual 'keep first' +check $expected_err $actual_err + +# check -create +$rcvstore +newfolder -nocreate -create <${MH_TEST_DIR}/Mail/inbox/1 \ + >$actual 2>&1 +check $expected $actual 'keep first' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/newfolder/1" \ + 'keep first' +rmdir "${MH_TEST_DIR}/Mail/newfolder" + +# check addition to unseen sequence +printf 'Unseen-Sequence: unseen\n' >> $MH +$rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence unseen -list' 'unseen: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' +#### Need to clear the unseen sequence. +touch "${MH_TEST_DIR}/Mail/inbox/11" +rmm 11 + +# check -nounseen +$rcvstore -nounseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence unseen -list' 'unseen: ' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -unseen +$rcvstore -nounseen -unseen <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence unseen -list' 'unseen: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -sequence +$rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence newseq -list' 'newseq: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check that default is -nozero +mark -sequence newseq all +$rcvstore -sequence newseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence newseq -list' 'newseq: 1-11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -zero +mark -sequence newseq all +$rcvstore -sequence newseq -zero <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence newseq -list' 'newseq: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -nozero +mark -sequence newseq all +$rcvstore -seq newseq -zero -nozero <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence newseq -list' 'newseq: 1-11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check that default is -public +$rcvstore -sequence pubseq <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence pubseq -list' 'pubseq: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -nopublic +$rcvstore -sequence privseq -nopublic <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence privseq -nopublic -list' 'privseq (private): 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check -public +$rcvstore -sequence pubseq -nopublic -public <${MH_TEST_DIR}/Mail/inbox/1 \ + >$actual 2>&1 +check $expected $actual 'keep first' +run_test 'mark -sequence pubseq -public -list' 'pubseq: 11' +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +#### Windows FAT filesystems don't support file permissions that +#### disallow read access, and chmod doesn't fail. If a test above +#### has failed, report that failure. Otherwise, report that we're +#### skipping the remainer of the test if chmod can't remove read +#### permission. +printf '\n' >${MH_TEST_DIR}/Mail/test-read-perms +chmod 600 ${MH_TEST_DIR}/Mail/test-read-perms +if [ "`find ${MH_TEST_DIR}/Mail/test-read-perms -perm 600`"x = ''x ]; then + if [ ${failed:-0} -eq 0 ]; then + echo "$Test $0 SKIP (cannot remove read permission on plain files)" + exit 77 + else + exit $failed + fi +else + rm -f ${MH_TEST_DIR}/Mail/test-read-perms +fi + +# check default Msg-Protect +msgprot=`mhparam msgprot` +$rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual 'keep first' +run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \ + "${MH_TEST_DIR}/Mail/inbox/11" +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' + +# check Msg-Protect profile entry +msgprot=640 +printf "Msg-Protect: $msgprot\n" >>$MH +$rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 +check $expected $actual +run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \ + "${MH_TEST_DIR}/Mail/inbox/11" +check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" + + +exit ${failed:-0}