Many tests were ported from nmh.
Two tests fail at the moment:
- tests/ali/test-ali: needs porting the bugfix from nmh
- tests/prompter/test-prompter: needs further investigation
# Common helper routines for test shell scripts
# -- intended to be sourced by them
+tmpfile="`mktemp`"
+trap '
+ rm -f "$tmpfile"
+ exit "$failed"
+' 0 1 2 15
+failed=0
+
+
test_skip()
{
- WHY="$1"
- echo "Test $0 SKIP ($WHY)"
- exit 120
+ echo "$0: $1"
+ failed=120
+ exit
}
# portable implementation of 'which' utility
fi
}
+require_locale()
+{
+ for locale in "$@"; do
+ if locale -a | grep -i "$locale" >/dev/null; then
+ return
+ fi
+ done
+ test_skip "no suitable locale available"
+}
+
# Some stuff for doing silly progress indicators
progress_update()
{
test -t 1 || return 0 # supress progress meter if non-interactive
- THIS="$1"
- FIRST="$2"
- LAST="$3"
- RANGE="$(expr $LAST - $FIRST ||:)"
- PROG="$(expr $THIS - $FIRST ||:)"
+ this="$1"
+ first="$2"
+ last="$3"
+ range="$(expr $last - $first ||:)"
+ prog="$(expr $this - $first ||:)"
# this automatically rounds to nearest integer
- PERC="$(expr 100 \* $PROG / $RANGE ||:)"
+ perc="$(expr 100 \* $prog / $range ||:)"
# note \r so next update will overwrite
- printf "%3d%%\r" $PERC
+ printf "%3d%%\r" $perc
}
progress_done()
test -t 1 || return 0 # supress progress meter if non-interactive
printf "100%%\n"
}
+
+
+
+#### Filter that squeezes blank lines, partially emulating GNU cat -s,
+#### but sufficient for our purpose.
+#### From http://www-rohan.sdsu.edu/doc/sed.html, compiled by Eric Pement.
+squeeze_lines()
+{
+ sed '/^$/N;/\n$/D'
+}
+
+#### Filter that converts non-breakable space U+00A0 to an ASCII space.
+prepare_space()
+{
+ sed 's/'"`printf '\\302\\240'`"'/ /g'
+}
+
+
+# first argument: command line to run
+# second argument: "normspace" to normalize the whitespace
+# stdin: expected output
+runandcheck()
+{
+ if [ "$2" = "normspace" ]; then
+ eval "$1" 2>&1 | prepare_space >"$tmpfile"
+ diff="`prepare_space | diff -ub - "$tmpfile" || :`"
+ else
+ eval "$1" >"$tmpfile" 2>&1
+ diff="`diff -u - "$tmpfile"`"
+ fi
+
+ if [ "$diff" ]; then
+ echo "$0: $1 failed"
+ echo "$diff"
+ failed=`expr "${failed:-0}" + 1`
+ fi
+}
printf("%-12s %4d\n", "Total", sum);
}
'
+
+exit `test "$failed" -eq 0`
set -e
if [ $return_value -eq 0 ] ; then
- printf "Test %s:\tPASS\n" "$1"
+ printf "Test %-60s\tPASS\n" "$1"
exit 0
elif [ $return_value -eq 120 ]; then
# indicates test was skipped (eg needed program not found)
# test itself should have printed a message about this,
# so print nothing here.
- :
+ printf "Test %-60s\tSKIP\n" "$1"
exit 2
else
- printf "Test %s:\tFAIL\n" "$1"
+ printf "Test %-60s\tFAIL\n" "$1"
exit 1
fi
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test ali
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+expected=$MH_TEST_DIR/$$.expected
+expected_err=$MH_TEST_DIR/$$.expected_err
+actual=$MH_TEST_DIR/$$.actual
+actual_err=$MH_TEST_DIR/$$.actual_err
+
+
+runandcheck "ali -help" <<!
+Usage: ali [switches] aliases ...
+ switches are:
+ -file aliasfile
+ -[no]list
+ -[no]normalize
+ -[no]user
+ -Version
+ -help
+!
+
+
+# check -Version
+case `ali -V` in
+ ali\ --*) ;;
+ * ) echo "$0: ali -V generated unexpected output" 1>&2
+ failed=`expr "${failed:-0}" + 1`;;
+esac
+
+
+# check with no arguments and no AliasFile profile component
+runandcheck 'ali' <<!
+!
+
+# check with nonexistent alias file
+runandcheck 'ali -file nonexistent || :' <<!
+ali: aliasing error in nonexistent: unable to read 'nonexistent'
+!
+
+cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
+me: me@example.com
+rush: geddy, alex, neil
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+EOF
+
+# check -file
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases" <<!
+me: me@example.com
+rush: geddy@example.com, alex@example.com, neil@example.com
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+!
+
+# check for a specific alias
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
+geddy@example.com, alex@example.com, neil@example.com
+!
+
+# check for a specific alias that doesn't exist
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases nonexistent" <<!
+nonexistent
+!
+
+# check -list
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -list" <<!
+me: me@example.com
+rush: geddy@example.com
+ alex@example.com
+ neil@example.com
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+!
+
+# check -nolist, which is the default
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -list -nolist" <<!
+me: me@example.com
+rush: geddy@example.com, alex@example.com, neil@example.com
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+!
+
+# check -user
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -user geddy@example.com" <<!
+rush, geddy
+!
+
+# check -nouser
+runandcheck \
+ "ali -file ${MH_TEST_DIR}/Mail/aliases -user -nouser geddy@example.com" <<!
+geddy@example.com
+!
+
+# check expansion of first address of blind list [Bug #15604]
+cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
+rush: Rush: geddy, alex, neil
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+EOF
+
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
+Rush: geddy@example.com, alex@example.com, neil@example.com
+!
+
+# check that aliases followed by ; are not expanded [Bug #15604]
+cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
+rush: Rush: geddy, alex, neil;
+geddy: geddy@example.com
+alex: alex@example.com
+neil: neil@example.com
+EOF
+
+runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
+Rush: geddy@example.com, alex@example.com, neil;
+!
+
+
+exit $failed
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test anno
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# check -help
+runandcheck "anno -help" <<!
+Usage: anno [+folder] [msgs] [switches]
+ switches are:
+ -component field
+ -[no]date
+ -text body
+ -Version
+ -help
+ -list
+ -delete
+ -number
+ -append
+ -[no]preserve
+!
+
+
+# check -Version
+case `anno -V` in
+ anno\ --*) ;;
+ * ) printf '%s: anno -V generated unexpected output\n' "$0" >&2
+ failed=`expr "${failed:-0}" + 1`;;
+esac
+
+
+# check unknown switch
+runandcheck "anno -nonexistent ||:" <<!
+anno: -nonexistent unknown
+!
+
+
+cp "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+# check with no switches
+
+runandcheck 'anno -comp Nmh-test 11' <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+Nmh-test:
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -component
+
+runandcheck 'anno -component Nmh-test 11' <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+Nmh-test:
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check +folder
+
+runandcheck 'anno -component Nmh-test +inbox 11' <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+Nmh-test:
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+
+
+# check msg
+
+folder -fast 2 >/dev/null
+
+runandcheck "anno 11 -component Nmh-test" <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+Nmh-test:
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+
+# Hard link the message and verify that the new one does get annotated.
+
+ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+runandcheck "anno 8 -component Nmh-test" <<!
+!
+runandcheck "diff -u $MH_TEST_DIR/Mail/inbox/8 $MH_TEST_DIR/Mail/inbox/8.link" <<!
+!
+
+
+# check -nodate. Without -text, it doesn't change the message.
+
+runandcheck "anno 11 -component Nmh-test -nodate" <<!
+anno: -nodate without -text is a no-op.
+!
+runandcheck "diff -u `mhpath f` `mhpath 11`" <<!
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -date
+
+runandcheck "anno 11 -component Nmh-test -nodate -date" <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+Nmh-test:
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+
+# check -append
+
+runandcheck "anno 11 -component Nmh-test -append" <<!
+!
+sed -e 's/^Nmh-test:.*/Nmh-test:/' "`mhpath 11`" >"`mhpath b`"
+runandcheck "cat `mhpath l`" <<!
+`awk '/^$/{print "Nmh-test:"}1' "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -list
+
+runandcheck "anno 11 -component Nmh-test -nodate -text 'test of anno -list'" <<!
+!
+runandcheck "cat `mhpath 11`" <<!
+Nmh-test: test of anno -list
+`cat "${MH_TEST_DIR}/Mail/inbox/1"`
+!
+runandcheck 'anno 11 -component Nmh-test -list' <<!
+test of anno -list
+!
+# check -list -number
+runandcheck 'anno 11 -component Nmh-test -list -number' <<!
+1 test of anno -list
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -delete
+
+runandcheck "anno 11 -component Nmh-test" <<!
+!
+runandcheck "anno 11 -component Nmh-test -delete" <<!
+!
+runandcheck "cat `mhpath 11`" <<!
+`cat "$MH_TEST_DIR/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -delete -number
+anno 11 -component Nmh-test -nodate -text 3
+anno 11 -component Nmh-test -nodate -text 2
+anno 11 -component Nmh-test -nodate -text 1
+runandcheck "anno 11 -component Nmh-test -delete -number 2" <<!
+!
+runandcheck "cat `mhpath 11`" <<!
+Nmh-test: 1
+Nmh-test: 3
+`cat "$MH_TEST_DIR/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -delete -all
+anno 11 -component Nmh-test -nodate -text 3
+anno 11 -component Nmh-test -nodate -text 2
+anno 11 -component Nmh-test -nodate -text 1
+runandcheck "anno 11 -component Nmh-test -delete -number all" <<!
+!
+runandcheck "cat `mhpath 11`" <<!
+`cat "$MH_TEST_DIR/Mail/inbox/1"`
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -preserve
+
+touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/11"
+output="`ls -l \`mhpath 11\``"
+runandcheck "anno 11 -component Nmh-test -preserve" <<!
+!
+runandcheck "anno 11 -component Nmh-test -preserve -delete" <<!
+!
+runandcheck "ls -l `mhpath 11`" <<!
+$output
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
+
+# check -nopreserve
+
+touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/11"
+out1="`ls -l \`mhpath 11\``"
+runandcheck "anno 11 -component Nmh-test -preserve -nopreserve" <<!
+!
+out2="`ls -l \`mhpath 11\``"
+runandcheck "test \"$out1\" = \"$out2\" || echo differs" <<!
+differs
+!
+
+touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/11"
+out1="`ls -l \`mhpath 11\``"
+runandcheck "anno 11 -component Nmh-test -preserve -nopreserve -delete" <<!
+!
+out2="`ls -l \`mhpath 11\``"
+runandcheck "test \"$out1\" = \"$out2\" || echo differs" <<!
+differs
+!
+cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11"
+
#!/bin/sh
######################################################
#
-# Test bogus headers (no blank line before body).
+# Test bogus headers (no blank line before body, etc.)
#
######################################################
-# TODO: Move to a common file tests can source; need more framework...
-failed=0
-check() {
- diff -u $expected $actual
- if [ $? -ne 0 ]; then
- failed=$((failed + 1))
- fi
-}
+. "$MH_TEST_COMMON"
expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
# Write message with bogus header field (missing blank line, really).
-msgfile=$(mhpath b)
-msgnum=$(basename $msgfile)
+msgfile="$(mhpath b)"
+msgnum="$(basename $msgfile)"
+
cat > $msgfile <<EOF
Date: Sun, 18 Dec 2005 00:52:39 +0100
From: foo@example.edu
I am a stupid spammer.
EOF
+
# check scan
-cat > $expected <<EOF
+runandcheck "scan $msgnum" <<!
11 2005-12-18 00:52 foo@example.edu test
-EOF
-scan $msgnum > $actual 2>&1
-check
+!
# check show
-cat > $expected <<EOF
+runandcheck "show $msgnum" <<!
Date: Sun, 18 Dec 2005 00:52:39 +0100
From: foo@example.edu
To: bar@example.edu
This is a multi-part message in MIME format.
I am a stupid spammer.
+!
+
+
+
+# check m_getfld() handling of empty header field
+msgfile="`mhpath b`"
+printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile"
+runandcheck "scan l" <<!
+scan: eof encountered in field "Received"
+??Format error (message 12) in component 2
+ 12 2013-01-12 09:07
+!
+
+
+
+# check m_getfld() handling of excessively long header field name
+
+msgfile="$MH_TEST_DIR/Mail/inbox/13"
+cat >"$msgfile" <<EOF
+Date: Tue, 15 Jan 2013 21:13:12 -0600
+ThisHeaderFieldNameIsWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayTooLong: OK
EOF
-show $msgnum > $actual 2>&1
-check
+runandcheck "scan l" <<!
+scan: field name "ThisHeaderFieldNameIsWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayTooLong" exceeds 997 bytes
+??Format error (message 13) in component 2
+ 13 2013-01-15 21:13
+!
+
+
+
+# # Cygwin has a BUFSIZ of 1024 so the error message gets truncated.
+# # Deal with that by grepping to verify that scan showed the proper error.
+# verify_string_in_file() {
+# if grep "$1" "$2" >/dev/null; then
+# :
+# else
+# echo "$0: did not receive expected error message \"$1\""
+# failed=`expr ${failed:-0} + 1`
+# fi
+# }
+# verify_string_in_file 'scan: field name "ThisHeaderFieldNameIsWa' "$actual_err"
+# verify_string_in_file 'exceeds 997' "$actual_err"
+# verify_string_in_file '??Format error (message 13) in component 2' "$actual_err"
+# rm -f "$actual_err"
+
+
+
+
+# check m_getfld() handling of long header field name without a colon
+
+msgfile="$MH_TEST_DIR/Mail/inbox/14"
+cat >"$msgfile" <<EOF
+Date: Thu, 17 Jan 2013 19:33:46 -0600
+If a header field name has at least 512 characters without a newline or colon, it will raise a format error in m_getfld(). Here is a test of that. 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
+
+Test
+
+
+EOF
+
+runandcheck "scan l" <<!
+scan: eol encountered in field "If a header field name has at least 512 characters without a newline or colon, it will raise a format error in m_getfld(). Here is a test of that. 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"
+??Format error (message 14) in component 2
+ 14 2013-01-17 19:33
+!
-exit $failed
--- /dev/null
+#!/bin/sh
+#
+# Tests to see if bursting messages works correctly.
+#
+
+. "$MH_TEST_COMMON"
+
+#
+# Create a test message that we can burst
+#
+
+msgpath="`mhpath b`"
+msgnum="${msgpath##*/}"
+
+cat > "$msgpath" <<EOF
+From: Test Burst Message <burst1@example.com>
+To: Test Recipient <recipient@example.com>
+Date: Friday, 29 Sep 2006 00:00:00
+Subject: Test digest
+
+------- Message one
+
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Date: Thursday, 28 Sep 2006 00:01:00
+Subject: Message one
+
+This is message one
+
+------- Message two
+
+From: Mister Burster <burst3@example.com>
+To: Nobody 2 <nobody2@example.com>
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: Message two
+
+This is message two
+For real.
+
+-------
+
+End of all messages
+EOF
+
+runandcheck "scan $msgnum" <<!
+ 11 2006-09-29 00:00 Test Burst Messag Test digest
+!
+
+runandcheck "burst $msgnum" <<!
+!
+
+runandcheck "scan $msgnum-l" <<!
+ 11 2006-09-29 00:00 Test Burst Messag Test digest
+ 12+ 2006-09-28 00:01 Mister Burster Message one
+ 13 2006-09-28 00:02 Mister Burster Message two
+!
+
+
+#
+# Create another test message that stresses the boundary checker a bit
+#
+
+msgpath="`mhpath b`"
+msgnum="${msgpath##*/}"
+
+cat >"$msgpath" <<EOF
+From: Test Burst Message <burst1@example.com>
+To: Test Recipient <recipient@example.com>
+Date: Friday, 29 Sep 2006 00:00:00
+Subject: Test digest
+
+This is a preamble
+------- Message one
+
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Date: Thursday, 28 Sep 2006 00:01:00
+Subject: Message one
+
+- -This is message one
+
+------- Message two
+From: Mister Burster <burst3@example.com>
+To: Nobody 2 <nobody2@example.com>
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: Message two
+
+This is message two
+- For real.
+------- Message three
+
+
+
+From: Mister Burster <burst4@example.com>
+To: Nobody 3 <nobody3@example.com>
+Date: Thursday, 28 Sep 2006 00:03:00
+Subject: Message three
+
+Will this one work?
+
+
+------ Message three
+End of all messages
+EOF
+
+runandcheck "burst $msgnum" <<!
+burst: message 14 not in digest format, continuing...
+!
+
+# mmh's burst(1) is picky about the input format
+
+exit
+
+# If we make burst to be more liberal in accepting not perfect
+# boundaries in the input, we can run the following tests
+
+
+runandcheck "scan $msgnum-l" <<!
+ 14 09/29 Test Burst Messag Test digest
+ 15+ 09/28 Mister Burster Message one
+ 16 09/28 Mister Burster Message two
+ 17 09/28 Mister Burster Message three
+!
+
+#
+# Check to see if each message is what we expect
+#
+
+folder -fast "$msgnum" >/dev/null
+
+runandcheck "next" <<!
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Date: Thursday, 28 Sep 2006 00:01:00
+Subject: Message one
+
+-This is message one
+!
+
+runandcheck "next" <<!
+From: Mister Burster <burst3@example.com>
+To: Nobody 2 <nobody2@example.com>
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: Message two
+
+This is message two
+For real.
+!
+
+runandcheck "next" <<!
+From: Mister Burster <burst4@example.com>
+To: Nobody 3 <nobody3@example.com>
+Date: Thursday, 28 Sep 2006 00:03:00
+Subject: Message three
+
+Will this one work?
+
+!
--- /dev/null
+#!/bin/sh
+#
+# Tests to see if bursting MIME messages works correctly.
+#
+
+. "$MH_TEST_COMMON"
+
+#
+# Create a one-part test message that we can burst
+#
+
+msgpath="`mhpath b`"
+msgnum="${msgpath##*/}"
+
+cat >"$msgpath" <<EOF
+From: Test Burst Message <burst1@example.com>
+To: Test Recipient <recipient@example.com>
+Date: Friday, 29 Sep 2006 00:00:00
+Subject: Test MIME digest
+MIME-Version: 1.0
+Content-type: message/rfc822
+
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Date: Thursday, 28 Sep 2006 00:01:00
+Subject: Message one
+
+- - This line should not be unstuffed
+
+EOF
+
+runandcheck "burst $msgnum" <<!
+burst: message 11 not in digest format, continuing...
+!
+
+runandcheck "scan $msgnum-l" <<!
+ 11 2006-09-29 00:00 Test Burst Messag Test MIME digest
+!
+
+#
+# Create another test message that does multipart/digest checking
+#
+
+msgpath="`mhpath b`"
+msgnum="${msgpath##*/}"
+
+cat > "$msgpath" <<EOF
+From: Test Burst Message <burst1@example.com>
+To: Test Recipient <recipient@example.com>
+Date: Friday, 29 Sep 2006 00:00:00
+Subject: Test digest
+MIME-Version: 1.0
+Content-Type: multipart/digest; boundary="----- =_aaaaaaaaaa0"
+
+This is a preamble
+
+------- =_aaaaaaaaaa0
+
+Content-Type: message/rfc822
+
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Date: Thursday, 28 Sep 2006 00:01:00
+Subject: Message one
+
+- -This is message one
+
+------- =_aaaaaaaaaa0
+
+From: Mister Burster <burst3@example.com>
+To: Nobody 2 <nobody2@example.com>
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: Message two
+
+This is message two
+- For real.
+
+------- =_aaaaaaaaaa0
+
+From: Mister Burster <burst4@example.com>
+To: Nobody 3 <nobody3@example.com>
+Date: Thursday, 28 Sep 2006 00:03:00
+Subject: Message three
+
+Will this one work?
+
+------- =_aaaaaaaaaa0--
+
+EOF
+
+runandcheck "burst $msgnum" <<!
+!
+
+runandcheck "scan $msgnum-l" <<!
+ 12 2006-09-29 00:00 Test Burst Messag Test digest
+ 13+ `date +'%Y-%m-%d %H:%M'`
+ 14 2006-09-28 00:02 Mister Burster Message two
+ 15 2006-09-28 00:03 Mister Burster Message three
+!
+
+#
+# Check to see if each message is what we expect
+#
+
+folder -fast "$msgnum" >/dev/null
+
+runandcheck "next" <<!
+
+part message/rfc822 157
+Date: Thu, 28 Sep 2006 00:01:00
+From: Mister Burster <burst2@example.com>
+To: Nobody 1 <nobody1@example.com>
+Subject: Message one
+
+part text/plain 21
+-This is message one
+!
+
+runandcheck "next" <<!
+Date: Thu, 28 Sep 2006 00:02:00
+From: Mister Burster <burst3@example.com>
+To: Nobody 2 <nobody2@example.com>
+Subject: Message two
+
+part text/plain 30
+This is message two
+For real.
+!
+
+#
+# The CR/LF that appears right before the boundary line is considered part
+# of the boundary line, so this has the practical effect of "eating" a
+# blank line if it's before the boundary (RFC 2046. 5.1.1). So make sure
+# a double blank line results in only one blank line at the end of a message.
+#
+
+runandcheck "next" <<!
+Date: Thu, 28 Sep 2006 00:03:00
+From: Mister Burster <burst4@example.com>
+To: Nobody 3 <nobody3@example.com>
+Subject: Message three
+
+part text/plain 20
+Will this one work?
+!
folder -create +testfolder > /dev/null
if [ ! -d "$MH_TEST_DIR/Mail/testfolder" ]; then
- exit 1
+ exit 1
fi
rmf +testfolder > /dev/null
if [ -d "$MH_TEST_DIR/Mail/testfolder" ]; then
- # Test failed
- exit 1
+ # Test failed
+ exit 1
fi
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test of the -recuse option
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+runandcheck "folder -create +testfolder" <<!
+testfolder+ has no messages
+!
+runandcheck "folder -create +testfolder/folder1" <<!
+testfolder/folder1+ has no messages
+!
+runandcheck "folder -create +testfolder/folder2" <<!
+testfolder/folder2+ has no messages
+!
+
+runandcheck "folder +testfolder -recurse" <<!
+testfolder+ has no messages ; (others)
+testfolder/folder1 has no messages
+testfolder/folder2 has no messages
+!
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test sortm
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+cd "$MH_TEST_DIR"
+
+runandcheck "sortm -help" <<!
+Usage: sortm [+folder] [msgs] [switches]
+ switches are:
+ -datefield field
+ -textfield field
+ -(no)textfield
+ -limit days
+ -(no)limit
+ -[no]verbose
+ -Version
+ -help
+!
+
+
+cat >$MH_TEST_DIR/Mail/inbox/11 <<EOF || exit 1
+From: Test11 <test11@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:01
+Alt-Date: Thu, 1 Sep 2005 00:00:00
+Subject: Re: common subject
+
+This is message number 11
+EOF
+
+cat >$MH_TEST_DIR/Mail/inbox/12 <<EOF || exit 1
+From: Test12 <test12@example.com>
+To: Some User <user@example.com>
+Date: Thu, 28 Sep 2006 23:59:59
+Alt-Date: Sat, 30 Sep 2006 00:00:00
+Subject: common subject
+
+This is message number 12
+EOF
+
+
+
+# check with no options
+
+runandcheck sortm <<!
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test1 Testing message 1
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test11 Re: common subject
+!
+
+
+
+# check +folder
+
+refile f +inbox
+folder -pack >/dev/null
+
+runandcheck "sortm +inbox" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test1 Testing message 1
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test11 Re: common subject
+!
+
+
+
+# check -verbose
+
+refile f +inbox
+folder -pack >/dev/null
+
+runandcheck "sortm -verbose" <<!
+sorting by datefield date
+renaming message chain from 12 to 1
+message 11 becomes message 12
+message 10 becomes message 11
+message 9 becomes message 10
+message 8 becomes message 9
+message 7 becomes message 8
+message 6 becomes message 7
+message 5 becomes message 6
+message 4 becomes message 5
+message 3 becomes message 4
+message 2 becomes message 3
+message 1 becomes message 2
+!
+runandcheck "scan" <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test1 Testing message 1
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test11 Re: common subject
+!
+
+
+
+# check -noverbose
+
+refile f +inbox
+folder -pack >/dev/null
+
+runandcheck "sortm -verbose -noverbose" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test1 Testing message 1
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test11 Re: common subject
+!
+
+
+
+# check msgs
+
+refile f +inbox
+folder -pack >/dev/null
+
+runandcheck "sortm f l" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+ 11 2006-09-29 00:00 Test11 Re: common subject
+ 12 2006-09-29 00:00 Test1 Testing message 1
+!
+
+
+
+# check -datefield
+
+runandcheck "sortm -datefield Alt-Date 1 11" <<!
+!
+runandcheck scan <<!
+ 1 2006-09-29 00:00 Test11 Re: common subject
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+ 11 2006-09-28 23:59 Test12 common subject
+ 12 2006-09-29 00:00 Test1 Testing message 1
+!
+
+
+
+# check -textfield subject (datefield major, subjects grouped)
+
+runandcheck "sortm -textfield subject" <<!
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test11 Re: common subject
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test1 Testing message 1
+!
+
+
+
+# check -nolimit
+
+runandcheck "sortm -textfield subject -limit 0 -nolimit" <<!
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test11 Re: common subject
+ 3 2006-09-29 00:00 Test2 Testing message 2
+ 4 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test4 Testing message 4
+ 6 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test6 Testing message 6
+ 8 2006-09-29 00:00 Test7 Testing message 7
+ 9 2006-09-29 00:00 Test8 Testing message 8
+ 10 2006-09-29 00:00 Test9 Testing message 9
+ 11 2006-09-29 00:00 Test10 Testing message 10
+ 12 2006-09-29 00:00 Test1 Testing message 1
+!
+
+
+
+# check -textfield subject -limit 0 (subject sort)
+
+refile 2-7 +inbox
+refile 1 +inbox
+folder -pack l >/dev/null
+
+runandcheck "sortm -textfield subject -limit 0" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-29 00:00 Test11 Re: common subject
+ 2 2006-09-28 23:59 Test12 common subject
+ 3 2006-09-29 00:00 Test1 Testing message 1
+ 4 2006-09-29 00:00 Test10 Testing message 10
+ 5 2006-09-29 00:00 Test2 Testing message 2
+ 6 2006-09-29 00:00 Test3 Testing message 3
+ 7 2006-09-29 00:00 Test4 Testing message 4
+ 8 2006-09-29 00:00 Test5 Testing message 5
+ 9 2006-09-29 00:00 Test6 Testing message 6
+ 10 2006-09-29 00:00 Test7 Testing message 7
+ 11 2006-09-29 00:00 Test8 Testing message 8
+ 12+ 2006-09-29 00:00 Test9 Testing message 9
+!
+
+
+
+# check -textfield -limit 0 (text sort)
+
+refile 2-7 +inbox
+refile 1 +inbox
+folder -pack l >/dev/null
+
+runandcheck "sortm -textfield from -limit 0" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-29 00:00 Test10 Testing message 10
+ 2 2006-09-29 00:00 Test11 Re: common subject
+ 3 2006-09-28 23:59 Test12 common subject
+ 4 2006-09-29 00:00 Test1 Testing message 1
+ 5 2006-09-29 00:00 Test2 Testing message 2
+ 6 2006-09-29 00:00 Test3 Testing message 3
+ 7 2006-09-29 00:00 Test4 Testing message 4
+ 8 2006-09-29 00:00 Test5 Testing message 5
+ 9 2006-09-29 00:00 Test6 Testing message 6
+ 10 2006-09-29 00:00 Test7 Testing message 7
+ 11 2006-09-29 00:00 Test8 Testing message 8
+ 12+ 2006-09-29 00:00 Test9 Testing message 9
+!
+
+
+
+# add another message
+
+cat >$MH_TEST_DIR/Mail/inbox/13 <<EOF || exit 1
+From: Test13 <test13@example.com>
+To: Some User <user@example.com>
+Date: Tue, 31 Oct 2006 23:59:59
+Subject: Re: common subject
+
+This is message number 13
+EOF
+
+
+
+# check -textfield with finite -limit that doesn't cover message 13
+
+refile 2-7 +inbox
+refile 1 +inbox
+folder -pack l >/dev/null
+
+runandcheck "sortm -textfield subject -limit 10" <<!
+!
+runandcheck "scan" <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test11 Re: common subject
+ 3 2006-09-29 00:00 Test5 Testing message 5
+ 4 2006-09-29 00:00 Test6 Testing message 6
+ 5 2006-09-29 00:00 Test7 Testing message 7
+ 6 2006-09-29 00:00 Test8 Testing message 8
+ 7 2006-09-29 00:00 Test9 Testing message 9
+ 8 2006-09-29 00:00 Test1 Testing message 1
+ 9 2006-09-29 00:00 Test2 Testing message 2
+ 10 2006-09-29 00:00 Test3 Testing message 3
+ 11 2006-09-29 00:00 Test4 Testing message 4
+ 12+ 2006-09-29 00:00 Test10 Testing message 10
+ 13 2006-10-31 23:59 Test13 Re: common subject
+!
+
+
+
+# check -textfield with finite -limit that does cover message 13
+
+refile 2-7 +inbox
+refile 1 +inbox
+folder -pack l >/dev/null
+
+runandcheck "sortm -textfield subject -limit 60" <<!
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test11 Re: common subject
+ 3 2006-10-31 23:59 Test13 Re: common subject
+ 4 2006-09-29 00:00 Test1 Testing message 1
+ 5 2006-09-29 00:00 Test2 Testing message 2
+ 6 2006-09-29 00:00 Test3 Testing message 3
+ 7 2006-09-29 00:00 Test4 Testing message 4
+ 8 2006-09-29 00:00 Test10 Testing message 10
+ 9 2006-09-29 00:00 Test5 Testing message 5
+ 10 2006-09-29 00:00 Test6 Testing message 6
+ 11 2006-09-29 00:00 Test7 Testing message 7
+ 12 2006-09-29 00:00 Test8 Testing message 8
+ 13+ 2006-09-29 00:00 Test9 Testing message 9
+!
+
+
+
+# check -notextfield
+
+refile 2-7 +inbox
+refile 1 +inbox
+folder -pack l >/dev/null
+
+runandcheck "sortm -textfield subject -limit 60 -notextfield" <<!
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test10 Testing message 10
+ 3 2006-09-29 00:00 Test5 Testing message 5
+ 4 2006-09-29 00:00 Test6 Testing message 6
+ 5 2006-09-29 00:00 Test7 Testing message 7
+ 6 2006-09-29 00:00 Test8 Testing message 8
+ 7 2006-09-29 00:00 Test9 Testing message 9
+ 8 2006-09-29 00:00 Test1 Testing message 1
+ 9 2006-09-29 00:00 Test2 Testing message 2
+ 10 2006-09-29 00:00 Test3 Testing message 3
+ 11 2006-09-29 00:00 Test4 Testing message 4
+ 12 2006-09-29 00:00 Test11 Re: common subject
+ 13+ 2006-10-31 23:59 Test13 Re: common subject
+!
+
+
+
+# check -check
+
+sed -e 's/Sep//' $MH_TEST_DIR/Mail/inbox/7 > $MH_TEST_DIR/Mail/inbox/14
+
+runandcheck "sortm" <<!
+sortm: can't parse date field in message 14, continuing...
+!
+runandcheck scan <<!
+ 1 2006-09-28 23:59 Test12 common subject
+ 2 2006-09-29 00:00 Test10 Testing message 10
+ 3 2006-09-29 00:00 Test5 Testing message 5
+ 4 2006-09-29 00:00 Test6 Testing message 6
+ 5 2006-09-29 00:00 Test7 Testing message 7
+ 6 2006-09-29 00:00 Test8 Testing message 8
+ 7 2006-09-29 00:00 Test9 Testing message 9
+ 8 2006-09-29 00:00 Test1 Testing message 1
+ 9 2006-09-29 00:00 Test2 Testing message 2
+ 10 2006-09-29 00:00 Test3 Testing message 3
+ 11 2006-09-29 00:00 Test4 Testing message 4
+ 12 2006-09-29 00:00 Test11 Re: common subject
+ 13+ 2006-10-31 23:59 Test13 Re: common subject
+ 14 0-01-00 00:00 Test9 Testing message 9
+!
+
#
######################################################
-output=`folder -total +inbox`
-if test x"$output" != x'TOTAL = 10 messages in 1 folder' ; then
- exit 1
-fi
+. "$MH_TEST_COMMON"
+runandcheck "folder -total +inbox" <<!
+TOTAL = 10 messages in 1 folder
+!
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test packf
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+runandcheck "packf -help" <<!
+Usage: packf [+folder] [msgs] [switches]
+ switches are:
+ -Version
+ -help
+!
+
+#runandcheck "packf -nonexistent" <<!
+#packf: -nonexistent unknown
+#!
+
+cd "$MH_TEST_DIR" || exit 1
+
+# check with no switches
+runandcheck "packf >msgbox" <<!
+!
+
+folder -create +inbox2 >/dev/null
+inc +inbox2 -file msgbox >/dev/null
+rm -f msgbox
+
+for i in `pick +inbox`; do
+ diff -u "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
+done
+
+runandcheck 'echo $i' <<!
+10
+!
+
+
+rmm -unlink +inbox2 a
+
+
+# check +folder
+runandcheck "packf +inbox >msgbox" <<!
+!
+inc +inbox2 -file msgbox >/dev/null
+rm -f msgbox
+for i in `pick +inbox`; do
+ diff -u "`mhpath +inbox "$i"`" "`mhpath +inbox2 "$i"`"
+done
+runandcheck "echo $i" <<!
+10
+!
+rmm -unlink +inbox2 a
+
+# check msgs
+runandcheck "packf +inbox 1 2 3 >msgbox" <<!
+!
+
+inc +inbox2 -file msgbox >/dev/null
+rm -f msgbox
+for i in `pick +inbox2`; do
+ diff -u "`mhpath +inbox "$i"`" "`mhpath +inbox2 "$i"`"
+done
+runandcheck "echo $i" <<!
+3
+!
+rmm -unlink +inbox2 a
+
THISDIR="tests/inc"
-if [ ! -z "$VALGRIND_ME" ]; then
+if [ "$VALGRIND_ME" ]; then
require_prog valgrind
# Lack of quotes here is important
VALGRIND="valgrind --quiet --error-exitcode=1"
#
######################################################
-# TODO: Move to a common file tests can source; need more framework...
-failed=0
-check() {
- diff -u $expected $actual
- if [ $? -ne 0 ]; then
- failed=$((failed + 1))
- fi
-}
+. "$MH_TEST_COMMON"
-# Make a draft file forwarding two messages.
-mkdraft() {
- cat > $draft <<EOF
+draft="$MH_TEST_DIR/mhbuild-$$.draft"
+
+
+cat >"$draft" <<!
To:
Cc:
Fcc: +sent
Subject:
--------
#forw [forwarded messages] +inbox 1 2
-EOF
-}
+!
-# Munge the Content-Id from the draft after mhbuild, so we have a reliable
-# value to check.
-mungedraft() {
- sed 's/\(Content-ID:\) <[^>][^>]*>/\1 <TESTID>/' $draft > $actual
-}
-draft=$MH_TEST_DIR/$$.draft
-expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
+runandcheck 'mhbuild "$draft"' <<!
+!
-# check mhbuild
-cat > $expected <<EOF
+runandcheck 'sed "/^Content-ID/s/:.*/: <TESTID>/" "$draft"' <<!
To:
Cc:
Fcc: +sent
This is message number 2
------- =_aaaaaaaaaa0--
-EOF
-mkdraft
-mhbuild $draft
-mungedraft
-check
-
-exit $failed
+!
#
######################################################
-# TODO: Move to a common file tests can source; need more framework...
-failed=0
+. "$MH_TEST_COMMON"
+
+draft="$MH_TEST_DIR/mhbuild-$$.draft"
export MM_CHARSET=UTF-8
-check() {
- diff -u $expected $actual
- if [ $? -ne 0 ]; then
- failed=$((failed + 1))
- fi
-}
-
-# Make a draft file forwarding two messages.
-mkdraft() {
- cat > $draft <<EOF
+
+# Subject
+
+cat >"$draft" <<!
From: Mr Foo Bar <foobar@example.com>
To: Somebody <somebody@example.com>
Subject: This is ä test
This is a test
-EOF
-}
-
-# Munge the Content-Id from the draft after mhbuild, so we have a reliable
-# value to check.
-mungedraft() {
- sed 's/\(Content-ID:\) <[^>][^>]*>/\1 <TESTID>/' $draft > $actual
-}
+!
-draft=$MH_TEST_DIR/$$.draft
-expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
+runandcheck 'mhbuild "$draft"' <<!
+!
-# check mhbuild
-cat > $expected <<EOF
+runandcheck 'sed "/^Content-ID:/s/:.*/: <TESTID>/" "$draft"' <<!
From: Mr Foo Bar <foobar@example.com>
To: Somebody <somebody@example.com>
Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
Content-ID: <TESTID>
This is a test
-EOF
-mkdraft
-mhbuild $draft
-mungedraft
-check
+!
-exit $failed
+
+# To + From
+
+cat >"$draft" <<!
+From: Jürgen <juergen@example.com>
+To: Gönül <goenuel@example.com>
+Subject: Names with Umlauts
+
+This is a test
+!
+
+runandcheck 'mhbuild "$draft"' <<!
+!
+
+runandcheck 'sed "/^Content-ID:/s/:.*/: <TESTID>/" "$draft"' <<!
+From: =?UTF-8?Q?J=C3=BCrgen?= <juergen@example.com>
+To: =?UTF-8?Q?G=C3=B6n=C3=BCl?= <goenuel@example.com>
+Subject: Names with Umlauts
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <TESTID>
+
+This is a test
+!
--- /dev/null
+# test mhbuild linebreak for quoted-printable
+
+. "$MH_TEST_COMMON"
+
+
+draft="$MH_TEST_DIR/mhbuild-$$.draft"
+
+cat >"$draft" <<!
+From: meillo
+To: meillo
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: mhbuild line breaking with quoted-printable
+----------------
+Füße <-- to ensure quoted-printable is used
+
+ 1 2 3 4 5 6 7
+1234567890123456789012345678901234567890123456789012345678901234567890
+123456789012345678901234567890123456789012345678901234567890123456789012345
+
+1234567890123456789012345678901234567890123456789012345678901234567890123.
+12345678901234567890123456789012345678901234567890123456789012345678901234.
+123456789012345678901234567890123456789012345678901234567890123456789012345.
+1234567890123456789012345678901234567890123456789012345678901234567890123456.
+
+12345678901234567890123456789012345678901234567890123456789012345678901234.xx
+123456789012345678901234567890123456789012345678901234567890123456789012345.xx
+1234567890123456789012345678901234567890123456789012345678901234567890123456.xx
+
+12345678901234567890123456789012345678901234567890123456789012345678901234..yy
+123456789012345678901234567890123456789012345678901234567890123456789012345..yy
+1234567890123456789012345678901234567890123456789012345678901234567890123456..yy
+!
+
+
+
+runandcheck 'mhbuild "$draft"' <<!
+!
+
+runandcheck 'sed "/^Content-ID:/s/:.*/: <TESTID>/" "$draft"' <<!
+From: meillo
+To: meillo
+Date: Thursday, 28 Sep 2006 00:02:00
+Subject: mhbuild line breaking with quoted-printable
+MIME-Version: 1.0
+Content-Type: text/plain; charset="UTF-8"
+Content-ID: <TESTID>
+Content-Transfer-Encoding: quoted-printable
+
+F=C3=BC=C3=9Fe <-- to ensure quoted-printable is used
+
+ 1 2 3 4 5 6 7
+1234567890123456789012345678901234567890123456789012345678901234567890
+123456789012345678901234567890123456789012345678901234567890123456789012345
+
+1234567890123456789012345678901234567890123456789012345678901234567890123.
+12345678901234567890123456789012345678901234567890123456789012345678901234.
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+=2E
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+6.
+
+12345678901234567890123456789012345678901234567890123456789012345678901234.=
+xx
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+=2Exx
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+6.xx
+
+12345678901234567890123456789012345678901234567890123456789012345678901234.=
+=2Eyy
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+=2E.yy
+123456789012345678901234567890123456789012345678901234567890123456789012345=
+6..yy
+!
--- /dev/null
+#!/bin/sh
+#
+# Test of various (well, start with one) function escapes.
+
+. "$MH_TEST_COMMON"
+
+test_skip "not implemented yet"
+
+
+cat >`mhpath b` <<EOF
+MIME-Version: 1.0
+From: sender@example.com
+To: recipient@example.com
+Subject: message with blank lines and trailing spaces
+Date: Mon, 29 Apr 2013 11:51:45 -0400
+
+There are two blank lines below. And there is a trailing space:
+And another trailing space:
+
+
+EOF
+
+
+# check nortrim (default), and that trailing whitespace in a
+# component is trimmed when filtering blank lines
+
+cat >"$MH_TEST_DIR/test.format" <<EOF
+body:component="> "
+EOF
+
+runandcheck "mhl -form $MH_TEST_DIR/test.format `mhpath l`" <<!
+> There are two blank lines below. And there is a trailing space:
+> And another trailing space:
+>
+>
+!
+
+
+
+# check rtrim
+
+cat >"$MH_TEST_DIR/test.format" <<EOF
+body:component="> ",rtrim
+EOF
+
+runandcheck "mhl -form $MH_TEST_DIR/test.format `mhpath l`" <<!
+> There are two blank lines below. And there is a trailing space:
+> And another trailing space:
+>
+>
+!
+
+
+rm -f "$MH_TEST_DIR/test.format"
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhlist with extended parameters (RFC 2231)
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+test_skip "not implemented yet"
+exit
+
+require_locale en_US.utf-8 en_US.utf8
+LC_ALL=en_US.UTF-8
+export LC_ALL
+
+
+#
+# Make some more complicated message parameters.
+#
+
+msgfile=`mhpath b`
+cat > $msgfile <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhlist ext param test 2
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset=us-ascii;
+ name*=utf-8''This%20%C3%AFs%20the%20filename
+
+This is a test
+
+------- =_aaaaaaaaaa0
+Content-Type: image/jpeg; name*3=" will it be?.jpg";
+ longparam*5*=Sp%C4%B1n%CC%88al%20Tap!;
+ longparam*2=It; name*1=if;
+ longparam*3=" Might be our Long Lost Band";
+ longparam*0*=UTF-8'en'I%20Cannot%20Believe%20It;
+ name*0="This is an example of a very long filename. I wonder ";
+ longparam*4*=%20The%20%C3%96ne%20And%20Only%20;
+ name*2=" this filename might be too long. It should not be. But";
+ longparam*1=", it Looks Like "
+Content-Transfer-Encoding: base64
+
+/9g=
+
+------- =_aaaaaaaaaa0--
+EOF
+
+runandcheck 'mhlist l -verbose' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 647
+ boundary="----- =_aaaaaaaaaa0"
+ 1 text/plain 15
+ charset="us-ascii"
+ name="This ïs the filename"
+ 2 image/jpeg 2
+ longparam="I Cannot Believe It, it Looks Like It Might be our Long Lost Band The Öne And Only Spın̈al Tap!"
+ name="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"
+!
+
+
+
+
+#
+# Write a message with some extended parameters
+#
+
+msgfile=`mhpath b`
+cat > $msgfile <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhlist ext param test 1
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset=us-ascii;
+ name*=utf-8''This%20%C3%AFs%20the%20filename
+
+This is a test
+
+------- =_aaaaaaaaaa0
+Content-Type: image/jpeg;
+ name*0="This is an example of a very long filename. I wonder ";
+ name*1=if;
+ name*2=" this filename might be too long. It should not be. But";
+ name*3=" will it be?.jpg"
+Content-Disposition: attachment;
+ filename*0="This is an example of a very long filename. I wonder ";
+ filename*1=if;
+ filename*2=" this filename might be too long. It should not be. But";
+ filename*3=" will it be?.jpg"
+Content-Transfer-Encoding: base64
+
+/9g=
+
+------- =_aaaaaaaaaa0--
+EOF
+
+# check to see if we decode parameters correctly.
+
+runandcheck 'mhlist l -verbose -disposition' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 637
+ boundary="----- =_aaaaaaaaaa0"
+ 1 text/plain 15
+ charset="us-ascii"
+ name="This ïs the filename"
+ 2 image/jpeg 2
+ name="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"
+ disposition "attachment"
+ filename="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"
+!
+
+#
+# Test out message/external-body types, and also make sure we will correctly
+# decode a URL wrapped with RFC 2017 rules.
+#
+
+msgfile=`mhpath b`
+cat > $msgfile <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhlist ext param test 3
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset=us-ascii;
+ name*=utf-8''This%20%C3%AFs%20the%20filename
+
+This is a test
+
+------- =_aaaaaaaaaa0
+Content-Type: message/external-body; access-type="url";
+ url*1="/that/should-be-wrapped/image.jpeg";
+ url*0="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url"
+
+Content-Type: image/jpeg
+Content-Description: Test of a long URL
+Content-Disposition: attachment; filename=image.jpeg
+
+------- =_aaaaaaaaaa0
+Content-Type: message/external-body; access-type="url";
+ url*0="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url
+ /that/should-be-wrapped/image.jpeg"
+
+Content-Type: image/jpeg
+Content-Description: Test of a long URL
+Content-Disposition: attachment; filename=image.jpeg
+
+------- =_aaaaaaaaaa0--
+EOF
+
+runandcheck 'mhlist l -verbose -disposition' <<!
+ msg part type/subtype size description
+ 13 multipart/mixed 775
+ boundary="----- =_aaaaaaaaaa0"
+ 1 text/plain 15
+ charset="us-ascii"
+ name="This ïs the filename"
+ 2 message/external-body 118
+ access-type="url"
+ url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
+ url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
+ access-type="url"
+ image/jpeg Test of a long URL
+ disposition "attachment"
+ filename="image.jpeg"
+ 3 message/external-body 118
+ access-type="url"
+ url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url /that/should-be-wrapped/image.jpeg"
+ url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
+ access-type="url"
+ image/jpeg Test of a long URL
+ disposition "attachment"
+ filename="image.jpeg"
+!
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhlist
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# check with no options and no current message
+
+
+runandcheck 'mhlist' <<!
+mhlist: no c message
+!
+
+
+# check with no options and current message
+folder +inbox 5 > /dev/null
+runandcheck mhlist <<!
+ msg part type/subtype size description
+ 5 text/plain 25
+!
+# FIXME: three should be no trailing spaces
+
+
+
+# check with folder and current message
+runandcheck "mhlist +inbox" <<!
+ msg part type/subtype size description
+ 5 text/plain 25
+!
+# FIXME: three should be no trailing spaces
+
+# check with specified message
+runandcheck "mhlist 5" <<!
+ msg part type/subtype size description
+ 5 text/plain 25
+!
+# FIXME: three should be no trailing spaces
+
+
+# check -file
+runandcheck "mhlist -file $MH_TEST_DIR/Mail/inbox/5" <<!
+ msg part type/subtype size description
+ 5 text/plain 25
+!
+# FIXME: three should be no trailing spaces
+
+# check -file -
+runandcheck "mhlist -file - < $MH_TEST_DIR/Mail/inbox/5" <<!
+ msg part type/subtype size description
+ 0 text/plain 25
+!
+# FIXME: three should be no trailing spaces
+
+
+# check message number greater than highest
+runandcheck 'mhlist 11' <<!
+mhlist: message 11 doesn't exist
+!
+
+
+# check multiple messages
+runandcheck "mhlist 2 8" <<!
+ msg part type/subtype size description
+ 2 text/plain 25
+ 8 text/plain 25
+!
+
+
+# Write message with a text/plain subpart.
+
+msgfile=`mhpath b`
+cat > $msgfile <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhlist test
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: multipart/related;
+ type="multipart/alternative";
+ boundary="subpart__1.1"
+
+--subpart__1.1
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Disposition: attachment; filename="test1"
+
+This is the first text/plain part, in a subpart.
+
+--subpart__1.1--
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Disposition: attachment; filename="test2"
+Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
+Content-Transfer-Encoding: quoted-printable
+
+This is the second text/plain part.
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1"; name="test3"
+Content-Disposition: attachment; filename="test3"
+
+This is the third text/plain part.
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Disposition: attachment; filename="test4"
+Content-Transfer-Encoding: base64
+
+VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K
+
+------- =_aaaaaaaaaa0--
+EOF
+
+# check -part
+runandcheck 'mhlist l -part 3' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 936
+ 1 multipart/related 180
+ 3 text/plain 35
+!
+
+
+# check -part of a subpart
+runandcheck 'mhlist l -part 1.1' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 936
+ 1 multipart/related 180
+ 1.1 text/plain 49
+!
+
+
+# check -type
+runandcheck 'mhlist l -type text/plain' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 936
+ 1 multipart/related 180
+ 1.1 text/plain 49
+ 2 text/plain 36
+ 3 text/plain 35
+ 4 text/plain 36
+!
+
+
+
+
+# check -verbose
+runandcheck 'mhlist 11 -verbose' <<!
+ msg part type/subtype size description
+ 11 multipart/mixed 936
+ boundary="----- =_aaaaaaaaaa0"
+ 1 multipart/related 180
+ type="multipart/alternative"
+ boundary="subpart__1.1"
+ 1.1 text/plain 49
+ charset="iso-8859-1"
+ 2 text/plain 36
+ charset="iso-8859-1"
+ 3 text/plain 35
+ charset="iso-8859-1"
+ name="test3"
+ 4 text/plain 36
+ charset="iso-8859-1"
+!
+
+
+
+# check MIME parser and m_getfld
+
+msgfile=`mhpath b`
+msgnum=`basename $msgfile`
+cat > $msgfile <<EOF
+To: recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ recipient@example.com, recipient@example.com, recipient@example.com,
+ re@example.com
+From: sender@example.com
+Subject: very long header
+Date: Wed, 4 Dec 2013 21:12:00 -0500
+MIME-Version: 1.0
+Content-Type: multipart/related; boundary="1"
+
+--1
+Content-Type: multipart/alternative; boundary="2"
+
+--2
+Content-Type: text/plain; charset="us-ascii"
+
+This is part 1.
+
+
+--2--
+
+--1
+Content-Type: text/plain; charset="us-ascii"
+
+This is part 2.
+
+
+--1--
+EOF
+
+runandcheck "mhlist l" <<!
+ msg part type/subtype size description
+ 12 multipart/related 204
+ 1 multipart/alternative 74
+ 1.1 text/plain 17
+ 2 text/plain 17
+!
+
+
+## now check mhlist output
+
+msgfile=`mhpath b`
+msgnum=`basename $msgfile`
+cat > $msgfile <<EOF
+To: example@example.org
+From: someone <someone@example.com>
+Subject: mhlist test
+Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
+Content-Type: multipart/mixed; boundary="BoundaryMixed"
+
+--BoundaryMixed
+Content-type: multipart/alternative;
+ boundary="BoundaryAlternative1"
+
+--BoundaryAlternative1
+Content-type: text/enriched; CHARSET=US-ASCII
+Content-transfer-encoding: 7bit
+
+This is supposedly enriched.
+
+--BoundaryAlternative1
+Content-type: text/plain; charset=ISO-8859-1; format=flowed
+Content-transfer-encoding: 8bit
+
+This is the body text/plain part.
+
+--BoundaryAlternative1
+Content-type: text/html; CHARSET=US-ASCII
+Content-transfer-encoding: 7bit
+
+<html><body><div><span style="line-height: 1.5;">
+This is the text/html body part.
+</span></div></body></html>
+
+--BoundaryAlternative1--
+
+--BoundaryMixed
+Content-type: multipart/alternative;
+ boundary="BoundaryAlternative2"
+
+--BoundaryAlternative2
+Content-type: audio/wav
+Content-transfer-encoding: 8bit
+
+pretend wav audio
+
+--BoundaryAlternative2
+Content-type: audio/mp3
+Content-transfer-encoding: 8bit
+
+pretend mp3 audio
+
+--BoundaryAlternative2
+Content-type: audio/basic
+Content-transfer-encoding: 8bit
+
+pretend basic audio
+
+--BoundaryAlternative2--
+
+--BoundaryMixed--
+EOF
+
+# check it -- vanilla output
+runandcheck "mhlist $msgnum" <<!
+ msg part type/subtype size description
+ 13 multipart/mixed 1038
+ 1 multipart/alternative 518
+ 1.1 text/html 111
+ 1.2 text/plain 34
+ 1.3 text/enriched 29
+ 2 multipart/alternative 326
+ 2.1 audio/basic 20
+ 2.2 audio/mp3 18
+ 2.3 audio/wav 18
+!
+
+
+# check it -- just part 1
+runandcheck "mhlist -part 1 $msgnum" <<!
+ msg part type/subtype size description
+ 13 multipart/mixed 1038
+ 1 multipart/alternative 518
+ 1.1 text/html 111
+ 1.2 text/plain 34
+ 1.3 text/enriched 29
+ 2 multipart/alternative 326
+!
+
+
+
+# check it -- ask for audio/basic in part 1, should get nothing
+runandcheck "mhlist -part 1 -type audio/basic $msgnum" <<!
+ msg part type/subtype size description
+ 13 multipart/mixed 1038
+ 1 multipart/alternative 518
+ 2 multipart/alternative 326
+!
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhparam
+#
+######################################################
+
+
+. "$MH_TEST_COMMON"
+
+
+# check -help
+runandcheck "mhparam -help" <<!
+Usage: mhparam [profile-components] [switches]
+ switches are:
+ -[no]components
+ -all
+ -Version
+ -help
+!
+
+
+# check -version
+case `mhparam -V` in
+ mhparam\ --*) ;;
+ * ) echo "$0: mhparam -v generated unexpected output" 1>&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown option
+runandcheck 'mhparam -nonexistent' <<!
+mhparam: -nonexistent unknown
+!
+
+# check -all
+cp "$MMH/profile" "$MMH/profile2"
+
+MMHP="$MMH/profile2"
+export MMHP
+
+# -all adds current folder
+runandcheck "mhparam -all" <<!
+Path: $MH_TEST_DIR/Mail
+Inbox: +inbox
+Current-Folder: inbox
+!
+
+
+# check -all with a component
+runandcheck "mhparam -all path >/dev/null" <<!
+mhparam: profile-components ignored with -all
+!
+
+# check -all with -components
+runandcheck "mhparam -all -components >/dev/null" <<!
+mhparam: -components ignored with -all
+!
+
+# check one component
+runandcheck 'mhparam path' <<!
+$MH_TEST_DIR/Mail
+!
+
+# check more than one component, which enables -component
+echo 'AliasFile: aliases' >>"$MMHP"
+runandcheck 'mhparam path AliasFile' <<!
+path: $MH_TEST_DIR/Mail
+AliasFile: aliases
+!
+
+
+#### This exits with non-zero status, so let runandcheck squash that:
+runandcheck 'mhparam formatproc rmmproc' <<!
+!
+
+
+# check -component
+runandcheck 'mhparam -component Path' <<!
+Path: $MH_TEST_DIR/Mail
+!
+
+# check -component, note that component name of argument is echoed exactly
+runandcheck 'mhparam -component path' <<!
+path: $MH_TEST_DIR/Mail
+!
+runandcheck 'mhparam -component PATH' <<!
+PATH: $MH_TEST_DIR/Mail
+!
+
+# check -nocomponent
+runandcheck 'mhparam -component -nocomponent path' <<!
+$MH_TEST_DIR/Mail
+!
+runandcheck 'mhparam -nocomponent path AliasFile' <<!
+$MH_TEST_DIR/Mail
+aliases
+!
+
+
+# check nonexistent component
+runandcheck 'mhparam nonexistent' <<!
+!
+
+
+# check that return status counts nonexistent components
+runandcheck "mhparam path context nonexistent1 nonexistent2 \
+ nonexistent3 >/dev/null; echo \$?" <<!
+3
+!
+# check that return status counts nonexistent components
+runandcheck "mhparam path context nonexistent1 nonexistent2 \
+ nonexistent3 inbox >/dev/null; echo \$?" <<!
+3
+!
+
+# mhparam -debug
+# Some of its output depends on configure options, so don't bother to
+# check for correctness here.
+runandcheck "mhparam -debug >/dev/null; echo \$?" <<!
+0
+!
+
+# check with text file that does not end with newline
+printf 'Editor: emacs' >>"$MMHP"
+runandcheck 'mhparam -nocomponent editor' <<!
+emacs
+!
+
+
+exit
+
+# FIXME: needs to be adjusted or removed ...
+
+# check each component in procs array in uip/mhparam.c
+# The tests don't override these, so they're default or configured values.
+# Note that cat is hardcoded here because the testsuite uses it for moreproc.
+
+runandcheck "mhparam -nocomponent \
+ context \
+ mh-sequences \
+ buildmimeproc \
+ fileproc \
+ foldprot \
+ incproc \
+ lproc \
+ mailproc \
+ mhlproc \
+ moreproc \
+ msgprot \
+ packproc \
+ postproc \
+ sendproc \
+ showmimeproc \
+ showproc \
+ version \
+ whatnowproc \
+ whomproc \
+ etcdir \
+ libexecdir \
+ datalocking \
+ spoollocking" <<!
+context
+.mh_sequences
+$MH_INST_DIR$bindir/mhbuild
+$MH_INST_DIR$bindir/refile
+700
+$bindir/inc
+more
+$MH_INST_DIR$bindir/mhmail
+$MH_INST_DIR$nmhlibexecdir/mhl
+cat
+600
+$bindir/packf
+$MH_INST_DIR$nmhlibexecdir/post
+$MH_INST_DIR$bindir/send
+$MH_INST_DIR$bindir/mhshow
+$MH_INST_DIR$nmhlibexecdir/mhl
+nmh-`cat ${srcdir}/VERSION`
+$MH_INST_DIR$bindir/whatnow
+$MH_INST_DIR$bindir/whom
+$nmhetcdirinst
+$MH_LIBEXEC_DIR
+fcntl
+${default_locking}
+!
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test prompter
+#
+######################################################
+
+
+. "$MH_TEST_COMMON"
+
+
+
+# check -help
+runandcheck "prompter -help" <<!
+Usage: prompter [switches] file
+ switches are:
+ -[no]prepend
+ -[no]rapid
+ -[no]body
+ -Version
+ -help
+!
+
+
+# check -version
+case `prompter -V` in
+ prompter\ --*) ;;
+ * ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+runandcheck 'prompter -nonexistent' <<!
+prompter: -nonexistent unknown
+!
+
+
+
+# check with no switches
+
+runandcheck 'prompter' <<!
+prompter: usage: prompter [switches] file
+!
+
+
+
+# check with file
+
+cat >$MH_TEST_DIR/prompter-file <<EOF
+Resent-From: sender@example.com
+Resent-To:
+Resent-cc:
+Resent-fcc:
+EOF
+
+printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n' | \
+ prompter $MH_TEST_DIR/prompter-file >/dev/null
+
+runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+--------
+message body
+!
+
+
+
+# check -noprepend
+
+cat >$MH_TEST_DIR/prompter-file <<EOF
+Resent-From: sender@example.com
+Resent-To:
+Resent-cc:
+Resent-fcc:
+--------
+message body
+EOF
+
+printf 'recipient@example.com\ncc@example.com\n+outbox\nappendage\n' | \
+ prompter -noprepend $MH_TEST_DIR/prompter-file >/dev/null
+
+runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+--------
+message body
+appendage
+!
+
+
+# check -prepend
+
+cat >$MH_TEST_DIR/prompter-file <<EOF
+Resent-From: sender@example.com
+Resent-To:
+Resent-cc:
+Resent-fcc:
+--------
+message body
+EOF
+
+printf 'recipient@example.com\ncc@example.com\n+outbox\nprependage\n' | \
+ prompter -noprepend -prepend $MH_TEST_DIR/prompter-file >/dev/null
+
+runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+--------
+prependage
+message body
+!
+
+
+# check -rapid
+
+runandcheck "</dev/null prompter -rapid $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+
+--------Enter initial text
+
+--------
+!
+
+
+
+# check -norapid
+
+runandcheck "</dev/null prompter -rapid -norapid $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+
+--------Enter initial text
+
+prependage
+message body
+--------
+!
+
+
+
+# check -body.
+
+runandcheck "echo 'woot woot' | prompter -nobody -body $MH_TEST_DIR/prompter-file" <<!
+Resent-From: sender@example.com
+Resent-To: recipient@example.com
+Resent-cc: cc@example.com
+Resent-fcc: +outbox
+
+--------Enter initial text
+
+woot woot
+prependage
+message body
+--------
+!
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test rcvdist
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+
+# check -help
+runandcheck "rcvdist -help" <<!
+Usage: rcvdist [switches] [switches for spost] address ...
+ switches are:
+ -form formfile
+ -Version
+ -help
+!
+
+
+# check -version
+case `rcvdist -V` in
+ rcvdist\ --*) ;;
+ * ) printf '%s: rcvdist -v generated unexpected output\n' "$0" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+runandcheck "rcvdist -nonexistent" <<!
+rcvdist: usage: rcvdist [switches] [switches for spost] address ...
+!
+
+# check with no switches
+runandcheck "rcvdist" <<!
+rcvdist: usage: rcvdist [switches] [switches for spost] address ...
+!
+
+
+exit
+### FIXME: port the following tests to mmh
+
+
+#### Use sendmail/pipe below to override default mts.
+mts_fakesendmail="${MHMTSCONF}-fakesendmail"
+sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
+printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
+MHMTSCONF="$mts_fakesendmail"
+
+# arguments: rcvdist switches
+test_rcvdist ()
+{
+ run_prog $rcvdist "$@"
+
+ # fakesendmail drops the message and any cc's into this mbox.
+ mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
+ inc -silent -file "$mbox"
+ rm -f "$mbox" "$mbox.map"
+
+ # It's hard to calculate the exact Date: header post is going to
+ # use, so we'll just use sed to remove the actual date so we can
+ # easily compare it against our "correct" output.
+ sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
+
+ check "$expected" "$actual"
+}
+
+# check with address
+cat > "$expected" <<EOF
+From: Test1 <test1@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Message-Id: 1@test.nmh
+Subject: Testing message 1
+Resent-From: `${MH_LIBEXEC_DIR}/ap -format '%(localmbox)' 0 | \
+ sed 's/^<\(.*\)>$/\1/'`
+Resent-To: recipient@example.com
+Resent-Date:
+
+This is message number 1
+EOF
+
+test_rcvdist recipient@example.com < "$MH_TEST_DIR/Mail/inbox/1"
+
+# check -form
+cat > "$expected" <<EOF
+From: Test2 <test2@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Message-Id: 2@test.nmh
+Subject: Testing message 2
+Resent-To: recipient@example.com
+Resent-From: Some User <user@example.com>
+Resent-Date:
+
+This is message number 2
+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
+
+test_rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com \
+ < "$MH_TEST_DIR/Mail/inbox/2"
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test rcvpack
+#
+######################################################
+
+
+. "$MH_TEST_COMMON"
+
+
+
+# check -help
+runandcheck "rcvpack -help" <<!
+Usage: rcvpack [switches] file
+ switches are:
+ -Version
+ -help
+!
+
+# check -Version
+case `rcvpack -V` in
+ rcvpack\ --*) ;;
+ * ) printf '%s: rcvpack -v generated unexpected output\n' "$0" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+# check unknown switch
+runandcheck "rcvpack -nonexistent" <<!
+rcvpack: -nonexistent unknown
+!
+
+# check with no switches
+runandcheck "rcvpack </dev/null" <<!
+
+!
+
+
+# check mbox creation
+runandcheck "rcvpack <$MH_TEST_DIR/Mail/inbox/1 $MH_TEST_DIR/Mail/mbox" <<!
+!
+inc -file $MH_TEST_DIR/Mail/mbox -silent
+diff -u "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11"
+
+
+# check append to existing mbox file
+runandcheck "rcvpack <$MH_TEST_DIR/Mail/inbox/2 $MH_TEST_DIR/Mail/mbox" <<!
+!
+inc -file $MH_TEST_DIR/Mail/mbox -silent
+diff -u "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/12"
+diff -u "$MH_TEST_DIR/Mail/inbox/2" "$MH_TEST_DIR/Mail/inbox/13"
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test rcvstore
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# check -help
+runandcheck "rcvstore -help" <<!
+Usage: rcvstore [+folder] [switches]
+ switches are:
+ -[no]create
+ -[no]unseen
+ -[no]public
+ -[no]zero
+ -sequence name
+ -Version
+ -help
+!
+
+
+# check -version
+case `rcvstore -V` in
+ rcvstore\ --*) ;;
+ * ) printf '%s: rcvstore -V generated unexpected output\n' "$0" >&2
+ failed=`expr ${failed:-0} + 1`;;
+esac
+
+
+# check unknown switch
+runandcheck "rcvstore -nonexistent" <<!
+rcvstore: -nonexistent unknown
+!
+
+
+# check with no switches and zero-length input message
+runandcheck "rcvstore </dev/null" <<!
+rcvstore: empty file
+!
+
+
+# check with no switches
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath l`"
+
+
+# check + of existing folder
+runandcheck "rcvstore +inbox <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check + of new folder
+runandcheck "rcvstore +newfolder <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
+rmf "+newfolder"
+
+
+# check -nocreate
+runandcheck "rcvstore +newfolder -nocreate <$MH_TEST_DIR/Mail/inbox/1" <<!
+rcvstore: folder $MH_TEST_DIR/Mail/newfolder doesn't exist
+!
+
+
+# check -create
+runandcheck "rcvstore +newfolder -nocreate -create <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+diff -u "`mhpath +inbox f`" "`mhpath +newfolder l`"
+rmf "+newfolder"
+
+
+# check addition to unseen sequence
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+
+
+
+# check -nounseen
+runandcheck "rcvstore -nounseen <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -unseen
+runandcheck "rcvstore -nounseen -unseen <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence u -list' <<!
+u: 11-13 15
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -sequence
+runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 16
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check that default is -nozero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 1-17
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -zero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq -zero <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 18
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check -nozero
+mark -sequence newseq a
+runandcheck "rcvstore -sequence newseq -zero -nozero <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence newseq -list' <<!
+newseq: 1-19
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check that default is -public
+runandcheck "rcvstore -sequence pubseq <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence pubseq -list' <<!
+pubseq: 20
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+# check -nopublic
+runandcheck "rcvstore -sequence privseq -nopublic <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence privseq -nopublic -list' <<!
+privseq (private): 21
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+# check -public
+runandcheck "rcvstore -sequence pubseq -nopublic -public <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck 'mark -sequence pubseq -public -list' <<!
+pubseq: 20 22
+!
+diff -u "`mhpath f`" "`mhpath l`"
+
+
+# check default Msg-Protect
+msgprot="`mhparam msgprot`"
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck "find $MH_TEST_DIR/Mail/inbox/23 -perm $msgprot" <<!
+$MH_TEST_DIR/Mail/inbox/23
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+
+
+# check Msg-Protect profile entry
+msgprot=640
+printf 'Msg-Protect: %s\n' "$msgprot" >>"`mhparam defpath`"
+runandcheck "rcvstore <$MH_TEST_DIR/Mail/inbox/1" <<!
+!
+runandcheck "find $MH_TEST_DIR/Mail/inbox/24 -perm $msgprot" <<!
+$MH_TEST_DIR/Mail/inbox/24
+!
+diff -u "`mhpath +inbox f`" "`mhpath +inbox l`"
+
#!/bin/sh
######################################################
#
-# Test a simple scan.
+# Test scan(1)
#
######################################################
-expected=$MH_TEST_DIR/$$.expected
-actual=$MH_TEST_DIR/$$.actual
+. "$MH_TEST_COMMON"
-cat > $expected <<EOF
+
+runandcheck "scan -width 80 +inbox" <<!
1 2006-09-29 00:00 Test1 Testing message 1
2 2006-09-29 00:00 Test2 Testing message 2
3 2006-09-29 00:00 Test3 Testing message 3
8 2006-09-29 00:00 Test8 Testing message 8
9 2006-09-29 00:00 Test9 Testing message 9
10 2006-09-29 00:00 Test10 Testing message 10
-EOF
+!
+
+
+runandcheck "scan -width 80 +inbox 2-6" <<!
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+!
+
+
+runandcheck "scan -width 80 +inbox 2-6" normspace <<!
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+!
+
+
+runandcheck "scan -width 50 +inbox 2 3 6" <<!
+ 2 2006-09-29 00:00 Test2 Testin
+ 3 2006-09-29 00:00 Test3 Testin
+ 6 2006-09-29 00:00 Test6 Testin
+!
+
+runandcheck "scan f l" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+
+show 5 >/dev/null
+runandcheck "scan" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5+ 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+
+runandcheck "scan p c n" <<!
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5+ 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+!
+
+runandcheck "scan c:3" <<!
+ 5+ 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+!
+
+runandcheck "scan -form scan.nmh" <<!
+ 1 09/29 Test1 Testing message 1
+ 2 09/29 Test2 Testing message 2
+ 3 09/29 Test3 Testing message 3
+ 4 09/29 Test4 Testing message 4
+ 5+ 09/29 Test5 Testing message 5
+ 6 09/29 Test6 Testing message 6
+ 7 09/29 Test7 Testing message 7
+ 8 09/29 Test8 Testing message 8
+ 9 09/29 Test9 Testing message 9
+ 10 09/29 Test10 Testing message 10
+!
+
+runandcheck "scan -form scan.mailx" <<!
+ N 1 Test1 Fri Sep 29 00:00 Testing message 1
+ N 2 Test2 Fri Sep 29 00:00 Testing message 2
+ N 3 Test3 Fri Sep 29 00:00 Testing message 3
+ N 4 Test4 Fri Sep 29 00:00 Testing message 4
+>N 5 Test5 Fri Sep 29 00:00 Testing message 5
+ N 6 Test6 Fri Sep 29 00:00 Testing message 6
+ N 7 Test7 Fri Sep 29 00:00 Testing message 7
+ N 8 Test8 Fri Sep 29 00:00 Testing message 8
+ N 9 Test9 Fri Sep 29 00:00 Testing message 9
+ N 10 Test10 Fri Sep 29 00:00 Testing message 10
+!
-scan -width 80 +inbox > $actual
-diff -u $expected $actual
+runandcheck "scan -form '=%(msg) %{from}' 1-c" <<!
+1 Test1 <test1@example.com>
+2 Test2 <test2@example.com>
+3 Test3 <test3@example.com>
+4 Test4 <test4@example.com>
+5 Test5 <test5@example.com>
+!
--- /dev/null
+#!/bin/sh
+#
+# test scan(1) with multibytes
+
+. $MH_TEST_COMMON
+
+require_locale en_US.utf-8 en_US.utf8
+LC_ALL=en_US.UTF-8
+export LC_ALL
+
+
+cat >"$MH_TEST_DIR/Mail/inbox/11" <<!
+Subject: =?iso-8859-1?Q?Schl=FCssel?=
+Mime-Version: 1.0
+From: Bob <bob@example.org>
+Date: Mon, 22 Sep 2014 01:17:05 +0200
+Message-Id: <83C54147-7D2B-4B7F-9502-11C1EB9526BC@example.org>
+To: Alice <alice@example.net>
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain;
+ charset=iso-8859-1
+
+Hallo Alice,
+
+hier ist dein Schl=FCssel, ich hoffe das Signieren hat funktioniert. =
+Mein =F6ffentlicher Schl=FCssel liegt auf dem Keyserver.
+
+Viele Gr=FC=DFe
+Bob
+
+!
+
+runandcheck "scan 11 +inbox" <<!
+ 11 2014-09-22 01:17 Bob Schlüssel
+!
+
+
+LC_ALL=C
+runandcheck "scan 11 +inbox" <<!
+ 11 2014-09-22 01:17 Bob Schl?ssel
+!
--- /dev/null
+#!/bin/sh
+#
+# test show(1) with multibytes
+
+. $MH_TEST_COMMON
+
+require_locale en_US.utf-8 en_US.utf8
+LC_ALL=en_US.UTF-8
+export LC_ALL
+
+
+cat >"$MH_TEST_DIR/Mail/inbox/11" <<!
+Subject: =?iso-8859-1?Q?Schl=FCssel?=
+Mime-Version: 1.0
+From: Bob <bob@example.org>
+Date: Mon, 22 Sep 2014 01:17:05 +0200
+Message-Id: <83C54147-7D2B-4B7F-9502-11C1EB9526BC@example.org>
+To: Alice <alice@example.net>
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain;
+ charset=iso-8859-1
+
+Hallo Alice,
+
+hier ist dein Schl=FCssel, ich hoffe das Signieren hat funktioniert. =
+Mein =F6ffentlicher Schl=FCssel liegt auf dem Keyserver.
+
+Viele Gr=FC=DFe
+Bob
+!
+
+runandcheck "show 11 +inbox" <<!
+Date: Mon, 22 Sep 2014 01:17:05 +0200
+From: Bob <bob@example.org>
+To: Alice <alice@example.net>
+Subject: Schlüssel
+
+part text/plain 151
+Hallo Alice,
+
+hier ist dein Schlüssel, ich hoffe das Signieren hat funktioniert. \
+Mein öffentlicher Schlüssel liegt auf dem Keyserver.
+
+Viele Grüße
+Bob
+!