summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-11-09 09:52:48 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-11-09 09:52:48 (GMT)
commit2aaec27bc466a9c64e7504697b3adf09c11c274a (patch) (side-by-side diff)
tree03d35eb070e58961afc1eb4c3ceceb7f0ee2c4a7
parent3d889508a084c2c0ea2a2741e2b3dba86e8ef7c7 (diff)
downloadmailutils-2aaec27bc466a9c64e7504697b3adf09c11c274a.tar.gz
mailutils-2aaec27bc466a9c64e7504697b3adf09c11c274a.tar.bz2
Fix mda testsuite
The testsuite should work no matter what the selected default mailbox format. * mda/tests/atlocal.in (dumpmail): New function. * mda/tests/forward.at: Use dumpmail to read the mailbox. * mda/tests/mda.at: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mda/tests/atlocal.in31
-rw-r--r--mda/tests/forward.at10
-rw-r--r--mda/tests/mda.at32
3 files changed, 55 insertions, 18 deletions
diff --git a/mda/tests/atlocal.in b/mda/tests/atlocal.in
index 3bd76a1..89458b9 100644
--- a/mda/tests/atlocal.in
+++ b/mda/tests/atlocal.in
@@ -3,4 +3,33 @@
# Copyright (C) 2004-2019 Free Software Foundation, Inc.
PATH=@abs_builddir@:@abs_top_builddir@/mda:$top_srcdir:$srcdir:$PATH
-INPUT_MSG=$abs_top_srcdir/mda/tests/input.msg
+INPUT_MSG=$abs_top_srcdir/mda/tests/input.msg
+MU_DEFAULT_SCHEME=@MU_DEFAULT_SCHEME@
+dumpmail() {
+ case $MU_DEFAULT_SCHEME in
+ mbox)
+ sed -e '/^From /d' -e '$d' $1
+ ;;
+ dotmail)
+ sed -e '/^\.$/d' $1
+ ;;
+ mh)
+ sed -e /^X-IMAPbase:/d\
+ -e /^X-UID:/d\
+ -e /^X-Envelope-Sender:/d\
+ -e /^X-Envelope-Date:/d $1/1
+ ;;
+ maildir)
+ f=$(find $1/new -type f | head -n 1)
+ if test -n $f; then
+ sed -e /^X-IMAPbase:/d\
+ -e /^X-UID:/d\
+ -e /^X-Envelope-Sender:/d\
+ -e /^X-Envelope-Date:/d $f
+ fi
+ ;;
+ *) # Should not happen
+ echo >&2 "Default mailbox format is uknown"
+ esac
+}
+
diff --git a/mda/tests/forward.at b/mda/tests/forward.at
index 96170ad..0328e2d 100644
--- a/mda/tests/forward.at
+++ b/mda/tests/forward.at
@@ -50,9 +50,7 @@ cat > experr <<EOT
testmda: notice: skipping forward file $forward: already processed
EOT
-echo ENVELOPE > expout.0
-cat $INPUT_MSG >> expout.0
-echo "" >> expout.0
+cat $INPUT_MSG > expout.0
echo "ENVELOPE FROM: gulliver@example.net" > expout.1
echo "ENVELOPE TO: <foo@bar.baz>" >> expout.1
@@ -67,12 +65,8 @@ testmda --from gulliver@example.net $1 < $INPUT_MSG || exit $?
for name in $namelist
do
- if test -f spool/$name; then
- sed '1s/From gulliver@example.net.*/ENVELOPE/' spool/$name | \
+ dumpmail spool/$name | \
cmp expout.0 - >/dev/null || echo "$name mailbox mismatch" >&2
- else
- echo "$name missed message" >&2
- fi
done
if test -f mta.diag; then
diff --git a/mda/tests/mda.at b/mda/tests/mda.at
index 6623fb6..711520e 100644
--- a/mda/tests/mda.at
+++ b/mda/tests/mda.at
@@ -25,13 +25,11 @@ AT_SETUP([mda])
AT_KEYWORDS([mda mda0])
AT_CHECK([
-echo ENVELOPE > expout
-cat $INPUT_MSG >> expout
-echo "" >> expout
+cat $INPUT_MSG > expout
mkdir spool
TESTMDA_CONF
testmda --from gulliver@example.net root < $INPUT_MSG || exit $?
-sed '1s/From gulliver@example.net.*/ENVELOPE/' spool/root
+dumpmail spool/root
],
[0],
[expout])
@@ -43,13 +41,29 @@ AT_SETUP([mda, explicit envelope])
AT_KEYWORDS([mda mda1])
AT_CHECK([
-echo "From gulliver Thu Oct 7 19:10:57 2010" > expout
-cat $INPUT_MSG >> expout
+date="Thu Oct 7 19:10:57 2010"
+envelope="From gulliver $date"
+echo $envelope > msg
+cat $INPUT_MSG >> msg
+cat $INPUT_MSG > expout
mkdir spool
TESTMDA_CONF
-testmda --from gulliver@example.net root < expout || exit $?
-echo "" >> expout
-cat spool/root
+testmda --from gulliver@example.net root < msg || exit $?
+dumpmail spool/root
+case $MU_DEFAULT_SCHEME in
+mbox)
+ head -1 spool/root
+ echo $envelope >> expout
+ ;;
+mh)
+ sed -n -e '/^X-Envelope-Date: */s///p' spool/root/1
+ echo $date >> expout
+ ;;
+maildir)
+ sed -n -e '/^X-Envelope-Date: */s///p' $(find spool/root/new -type f | head -n 1)
+ echo $date >> expout
+ ;;
+esac
],
[0],
[expout])

Return to:

Send suggestions and report system problems to the System administrator.