[PATCH 03/13] test: add 'Emacs' prereq to dependent 'crypto' tests

Thomas Jost schnouki at schnouki.net
Mon Oct 3 09:47:17 PDT 2011


From: Pieter Praet <pieter at praet.org>

Adds a new test that checks for the presence of 'emacs',
and adds that test as a prereq to all subsequent tests
that rely on Emacs.

This causes tests with unmet dependencies to be skipped.

Right now, all crypto tests do depend on Emacs, because it
is used to generate the signed/encrypted messages that are
needed by the tests.

Signed-off-by: Pieter Praet <pieter at praet.org>
---
 test/crypto |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/test/crypto b/test/crypto
index 4ee318f..cd64275 100755
--- a/test/crypto
+++ b/test/crypto
@@ -7,9 +7,20 @@
 test_description='PGP/MIME signature verification and decryption'
 . ./test-lib.sh
 
+# Emacs is a prereq.
+test_set_bin_prereq screen "GNU Screen" SCREEN
+test_have_prereq SCREEN && test_set_bin_prereq emacs "Emacs" EMACS
+
 # GnuPG is a prereq.
 test_set_bin_prereq gpg "GnuPG" GPG
 
+# Some tests have multiple prereqs, but the test_expect_* functions
+# accept only a single argument as prereq tag, and using test_have_prereq
+# in and around tests causes various errors for me, so a dirty workaround
+# will have to do for the time being.
+test_have_prereq EMACS && test_have_prereq GPG \
+    && test_set_prereq EMACS+GPG
+
 
 add_gnupg_home ()
 {
@@ -36,7 +47,7 @@ test_have_prereq GPG && FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-col
 # although I can't figure out why
 add_email_corpus
 
-test_expect_success GPG 'emacs delivery of signed message' \
+test_expect_success EMACS+GPG 'emacs delivery of signed message' \
 'emacs_deliver_message \
     "test signed message 001" \
     "This is a test signed message." \
@@ -69,7 +80,7 @@ expected='[[[{"id": "XXXXX",
  {"id": 3,
  "content-type": "application/pgp-signature"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -104,7 +115,7 @@ expected='[[[{"id": "XXXXX",
  {"id": 3,
  "content-type": "application/pgp-signature"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -137,7 +148,7 @@ expected='[[[{"id": "XXXXX",
  {"id": 3,
  "content-type": "application/pgp-signature"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 mv "${GNUPGHOME}"{.bak,}
@@ -146,7 +157,7 @@ mv "${GNUPGHOME}"{.bak,}
 cat <<EOF >TESTATTACHMENT
 This is a test file.
 EOF
-test_expect_success GPG 'emacs delivery of encrypted message with attachment' \
+test_expect_success EMACS+GPG 'emacs delivery of encrypted message with attachment' \
 'emacs_deliver_message \
     "test encrypted message 001" \
     "This is a test encrypted message.\n" \
@@ -180,7 +191,7 @@ Non-text part: application/octet-stream
 part}
 body}
 message}'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -215,7 +226,7 @@ expected='[[[{"id": "XXXXX",
  "content-type": "application/octet-stream",
  "filename": "TESTATTACHMENT"}]}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -226,7 +237,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 GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -236,7 +247,7 @@ notmuch show \
     --part=5 \
     --decrypt \
     subject:"test encrypted message 001" >OUTPUT
-test_expect_equal_file GPG OUTPUT TESTATTACHMENT
+test_expect_equal_file EMACS+GPG OUTPUT TESTATTACHMENT
 
 test_begin_subtest "decryption failure with missing key"
 mv "${GNUPGHOME}"{,.bak}
@@ -263,12 +274,12 @@ expected='[[[{"id": "XXXXX",
  {"id": 3,
  "content-type": "application/octet-stream"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 mv "${GNUPGHOME}"{.bak,}
 
-test_expect_success GPG 'emacs delivery of encrypted + signed message' \
+test_expect_success EMACS+GPG 'emacs delivery of encrypted + signed message' \
 'emacs_deliver_message \
     "test encrypted message 002" \
     "This is another test encrypted message.\n" \
@@ -303,7 +314,7 @@ expected='[[[{"id": "XXXXX",
  "content-type": "text/plain",
  "content": "This is another test encrypted message.\n"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -317,7 +328,7 @@ On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite at notmuchmail.org> w
 Non-text part: multipart/encrypted
 Non-text part: application/pgp-encrypted
 > This is another test encrypted message.'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
@@ -358,7 +369,7 @@ expected='[[[{"id": "XXXXX",
  {"id": 3,
  "content-type": "application/pgp-signature"}]}]},
  []]]]'
-test_expect_equal GPG \
+test_expect_equal EMACS+GPG \
     "$output" \
     "$expected"
 
-- 
1.7.6.4



More information about the notmuch mailing list