about summary refs log tree commit diff
path: root/t
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-05-09 14:43:00 +0200
committerLeah Neukirchen <leah@vuxu.org>2021-05-09 22:00:32 +0200
commit669af4ffcae6d6515f8de7a53c407ca26d1263c6 (patch)
treea3ebd4f48622e6e6db9d5f576fa874c51d8b7c8d /t
parent7d049328136b466a33279ced6e2de46e4a41a3ef (diff)
downloadmblaze-669af4ffcae6d6515f8de7a53c407ca26d1263c6.tar.gz
mblaze-669af4ffcae6d6515f8de7a53c407ca26d1263c6.tar.xz
mblaze-669af4ffcae6d6515f8de7a53c407ca26d1263c6.zip
mdeliver: ignore last empty line of mbox entries
https://www.loc.gov/preservation/digital/formats/fdd/fdd000383.shtml
> Each message is immediately prefaced by a separation line and
> terminated by an empty line.

Bug discovered by skarnet.

Fixes #207.
Diffstat (limited to 't')
-rwxr-xr-xt/1900-mdeliver.t69
1 files changed, 69 insertions, 0 deletions
diff --git a/t/1900-mdeliver.t b/t/1900-mdeliver.t
new file mode 100755
index 0000000..179cbbe
--- /dev/null
+++ b/t/1900-mdeliver.t
@@ -0,0 +1,69 @@
+#!/bin/sh -e
+cd ${0%/*}
+. ./lib.sh
+plan 2
+
+rm -rf test.dir
+mkdir test.dir
+cd test.dir
+
+mmkdir inbox
+
+cat <<EOF >tmp.1
+Subject: message 1
+
+This is message 1.
+EOF
+
+cat <<EOF >tmp.2
+Subject: message 2
+
+This is message 2.  It has a trailing empty line.
+
+EOF
+
+printf >tmp.3 'Subject: message 3
+
+This is message 3.  It has a no trailing newline, oops.'
+
+cat <<EOF >tmp.4
+Subject: message 4
+
+
+
+This is message 4.  It has multiple trailing empty lines.
+
+
+EOF
+
+mexport ./tmp.1 | mdeliver -M inbox/
+check 'message 1 is delivered verbatim via mbox' 'cmp ./tmp.1 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mexport ./tmp.2 | mdeliver -M inbox/
+check 'message 2 is delivered verbatim via mbox' 'cmp ./tmp.2 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mexport ./tmp.3 | mdeliver -M inbox/
+check 'message 3 gets a newline via mbox' 'awk 1 ./tmp.3 | cmp - ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mexport ./tmp.4 | mdeliver -M inbox/
+check 'message 4 gets delivered verbatim via mbox' 'cmp ./tmp.4 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mdeliver inbox/ <./tmp.1
+check 'message 1 is delivered verbatim via stdin' 'cmp ./tmp.1 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mdeliver inbox/ <./tmp.2
+check 'message 2 is delivered verbatim via stdin' 'cmp ./tmp.2 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mdeliver inbox/ <./tmp.3
+check 'message 3 gets a newline via stdin' 'cmp ./tmp.3 ./inbox/new/*:2,'
+rm -f ./inbox/new/*
+
+mdeliver inbox/ <./tmp.4
+check 'message 4 is delivered verbatim via stdin' 'cmp ./tmp.4 ./inbox/new/*:2,'
+rm -f ./inbox/new/*