[PATCH 3/6] test: add 'GnuPG' prereq to dependent 'crypto' tests
Thomas Jost
schnouki at schnouki.net
Wed Nov 16 06:33:52 PST 2011
From: Pieter Praet <pieter at praet.org>
Adds a new test that checks for the presence of 'gpg',
and adds that test as a prereq to all subsequent tests
that rely on GnuPG.
This causes tests with unmet dependencies to be skipped.
Signed-off-by: Pieter Praet <pieter at praet.org>
---
test/crypto | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/test/crypto b/test/crypto
index 0af4aa8..eca59b6 100755
--- a/test/crypto
+++ b/test/crypto
@@ -7,11 +7,16 @@
test_description='PGP/MIME signature verification and decryption'
. ./test-lib.sh
+# GnuPG is a prereq.
+test_set_bin_prereq gpg "GnuPG" GPG
+
+
add_gnupg_home ()
{
local output
[ -d ${GNUPGHOME} ] && return
mkdir -m 0700 "$GNUPGHOME"
+ test_have_prereq GPG || return
gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1
test_debug "cat $GNUPGHOME/import.log"
if (gpg --quick-random --version >/dev/null 2>&1) ; then
@@ -25,13 +30,13 @@ add_gnupg_home ()
add_gnupg_home
# get key fingerprint
-FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)
+test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)
# for some reason this is needed for emacs_deliver_message to work,
# although I can't figure out why
add_email_corpus
-test_expect_success 'emacs delivery of signed message' \
+test_expect_success GPG 'emacs delivery of signed message' \
'emacs_deliver_message \
"test signed message 001" \
"This is a test signed message." \
@@ -64,7 +69,7 @@ expected='[[[{"id": "XXXXX",
{"id": 3,
"content-type": "application/pgp-signature"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -99,7 +104,7 @@ expected='[[[{"id": "XXXXX",
{"id": 3,
"content-type": "application/pgp-signature"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -132,7 +137,7 @@ expected='[[[{"id": "XXXXX",
{"id": 3,
"content-type": "application/pgp-signature"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
mv "${GNUPGHOME}"{.bak,}
@@ -141,7 +146,7 @@ mv "${GNUPGHOME}"{.bak,}
cat <<EOF >TESTATTACHMENT
This is a test file.
EOF
-test_expect_success 'emacs delivery of encrypted message with attachment' \
+test_expect_success GPG 'emacs delivery of encrypted message with attachment' \
'emacs_deliver_message \
"test encrypted message 001" \
"This is a test encrypted message.\n" \
@@ -175,7 +180,7 @@ Non-text part: application/octet-stream
part}
body}
message}'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -210,7 +215,7 @@ expected='[[[{"id": "XXXXX",
"content-type": "application/octet-stream",
"filename": "TESTATTACHMENT"}]}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -221,7 +226,7 @@ output=$(notmuch show --format=json --part=4 --decrypt subject:"test encrypted m
expected='{"id": 4,
"content-type": "text/plain",
"content": "This is a test encrypted message.\n"}'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -231,7 +236,7 @@ notmuch show \
--part=5 \
--decrypt \
subject:"test encrypted message 001" >OUTPUT
-test_expect_equal_file OUTPUT TESTATTACHMENT
+test_expect_equal_file GPG OUTPUT TESTATTACHMENT
test_begin_subtest "decryption failure with missing key"
mv "${GNUPGHOME}"{,.bak}
@@ -258,12 +263,12 @@ expected='[[[{"id": "XXXXX",
{"id": 3,
"content-type": "application/octet-stream"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
mv "${GNUPGHOME}"{.bak,}
-test_expect_success 'emacs delivery of encrypted + signed message' \
+test_expect_success GPG 'emacs delivery of encrypted + signed message' \
'emacs_deliver_message \
"test encrypted message 002" \
"This is another test encrypted message.\n" \
@@ -298,7 +303,7 @@ expected='[[[{"id": "XXXXX",
"content-type": "text/plain",
"content": "This is another test encrypted message.\n"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -310,7 +315,7 @@ Subject: Re: test encrypted message 002
On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite at notmuchmail.org> wrote:
> This is another test encrypted message.'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
@@ -351,7 +356,7 @@ expected='[[[{"id": "XXXXX",
{"id": 3,
"content-type": "application/pgp-signature"}]}]},
[]]]]'
-test_expect_equal \
+test_expect_equal GPG \
"$output" \
"$expected"
--
1.7.7.3
More information about the notmuch
mailing list