summaryrefslogtreecommitdiff
path: root/tests/email-print-mime-structure.sh
blob: 0b70d73893aa1b94705182901a33381e5119d2cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

set -e

test_eml() {
    message="$1"
    shift
    diff -u "$message.out" <(./email-print-mime-structure "$@" <"$message.eml")
}

for eml in tests/email-print-mime-structure/*.eml; do
    base="${eml%%.eml}"
    pgpkey="$base.pgpkey"
    if [ -e "$pgpkey" ]; then
        printf "Testing %s (PGPy)\n" "${eml##*/}"
        test_eml "$base" --pgpkey "$pgpkey"

        testgpghome=$(mktemp -d)
        printf "Testing %s (GnuPG)\n" "${eml##*/}"
        gpg --homedir="$testgpghome" --batch --quiet --import <"$pgpkey"
        GNUPGHOME="$testgpghome" test_eml "$base" --use-gpg-agent
        rm -rf "$testgpghome"
    else
        printf "Testing %s\n" "${eml##*/}"
        test_eml "$base"
    fi
done