From e9e26fa3d84b9d38c4a33fb33f890b21b482ef13 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 25 Nov 2019 01:53:54 -0500 Subject: email-print-mime-structure: simple baseline test suite I want to ensure that any changes don't ultimately break the behavior of email-print-mime-structure. Signed-off-by: Daniel Kahn Gillmor --- Makefile | 3 +++ debian/control | 2 ++ tests/email-print-mime-structure.sh | 8 ++++++++ tests/email-print-mime-structure/alternative.eml | 18 ++++++++++++++++ tests/email-print-mime-structure/alternative.out | 3 +++ tests/email-print-mime-structure/attachment.eml | 26 ++++++++++++++++++++++++ tests/email-print-mime-structure/attachment.out | 5 +++++ tests/email-print-mime-structure/simple.eml | 9 ++++++++ tests/email-print-mime-structure/simple.out | 1 + 9 files changed, 75 insertions(+) create mode 100755 tests/email-print-mime-structure.sh create mode 100644 tests/email-print-mime-structure/alternative.eml create mode 100644 tests/email-print-mime-structure/alternative.out create mode 100644 tests/email-print-mime-structure/attachment.eml create mode 100644 tests/email-print-mime-structure/attachment.out create mode 100644 tests/email-print-mime-structure/simple.eml create mode 100644 tests/email-print-mime-structure/simple.out diff --git a/Makefile b/Makefile index cd8f592..de2a784 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ COMPLETIONS=completions/bash/email-print-mime-structure all: $(MANPAGES) $(COMPLETIONS) +check: + ./tests/email-print-mime-structure.sh + clean: rm -f $(MANPAGES) rm -rf completions diff --git a/debian/control b/debian/control index 72b57c3..bf49458 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,9 @@ Build-Depends: bash-completion, debhelper (>= 10), dh-elpa, + diffutils , perl, + python3 , python3-argcomplete, Vcs-Git: https://git.spwhitton.name/mailscripts Vcs-Browser: https://git.spwhitton.name/mailscripts diff --git a/tests/email-print-mime-structure.sh b/tests/email-print-mime-structure.sh new file mode 100755 index 0000000..5efa2ca --- /dev/null +++ b/tests/email-print-mime-structure.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +for eml in tests/email-print-mime-structure/*.eml; do + printf "Testing %s\n" "${eml##*/}" + diff -u "${eml%%.eml}.out" <(./email-print-mime-structure < "$eml") +done diff --git a/tests/email-print-mime-structure/alternative.eml b/tests/email-print-mime-structure/alternative.eml new file mode 100644 index 0000000..9b7723d --- /dev/null +++ b/tests/email-print-mime-structure/alternative.eml @@ -0,0 +1,18 @@ +Date: Sun, 24 Nov 2019 21:13:45 -0500 +Subject: test message +Message-ID: +From: Alice +To: Bob +Content-Type: multipart/alternative; boundary="abc123" + +--abc123 +Content-Type: text/plain + +This is a simple message + +--abc123 +Content-Type: text/html + +

This is a simple message

+ +--abc123-- diff --git a/tests/email-print-mime-structure/alternative.out b/tests/email-print-mime-structure/alternative.out new file mode 100644 index 0000000..1c0165a --- /dev/null +++ b/tests/email-print-mime-structure/alternative.out @@ -0,0 +1,3 @@ +└┬╴multipart/alternative 414 bytes + ├─╴text/plain 26 bytes + └─╴text/html 72 bytes diff --git a/tests/email-print-mime-structure/attachment.eml b/tests/email-print-mime-structure/attachment.eml new file mode 100644 index 0000000..31baa7c --- /dev/null +++ b/tests/email-print-mime-structure/attachment.eml @@ -0,0 +1,26 @@ +Date: Sun, 24 Nov 2019 21:13:45 -0500 +Subject: test message +Message-ID: +From: Alice +To: Bob +Content-Type: multipart/mixed; boundary="xyz" + +--xyz +Content-Type: multipart/alternative; boundary="abc123" + +--abc123 +Content-Type: text/plain + +This is a simple message + +--abc123 +Content-Type: text/html + +

This is a simple message

+ +--abc123-- +--xyz +Content-Type: text/plain +Content-Disposition: attachment; filename="test.txt" + +This is a simple attachment file. diff --git a/tests/email-print-mime-structure/attachment.out b/tests/email-print-mime-structure/attachment.out new file mode 100644 index 0000000..f2ca543 --- /dev/null +++ b/tests/email-print-mime-structure/attachment.out @@ -0,0 +1,5 @@ +└┬╴multipart/mixed 594 bytes + ├┬╴multipart/alternative 234 bytes + │├─╴text/plain 26 bytes + │└─╴text/html 72 bytes + └─╴text/plain attachment [test.txt] 33 bytes diff --git a/tests/email-print-mime-structure/simple.eml b/tests/email-print-mime-structure/simple.eml new file mode 100644 index 0000000..36facec --- /dev/null +++ b/tests/email-print-mime-structure/simple.eml @@ -0,0 +1,9 @@ +Date: Sun, 24 Nov 2019 21:13:45 -0500 +Subject: test message +Message-ID: +From: Alice +To: Bob + +This is a simple message + + diff --git a/tests/email-print-mime-structure/simple.out b/tests/email-print-mime-structure/simple.out new file mode 100644 index 0000000..7ac3514 --- /dev/null +++ b/tests/email-print-mime-structure/simple.out @@ -0,0 +1 @@ +└─╴text/plain 30 bytes -- cgit v1.2.3