[PATCH v3 06/16] Prefer gpg2 in the test suite if available
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 31 Jan 2016 20:39:51 +0000 (15:39 +1900)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:20:57 +0000 (16:20 -0700)
12/198bade5f0a3fc7b2d26e1e6377dd03446cafe [new file with mode: 0644]

diff --git a/12/198bade5f0a3fc7b2d26e1e6377dd03446cafe b/12/198bade5f0a3fc7b2d26e1e6377dd03446cafe
new file mode 100644 (file)
index 0000000..22cf8d8
--- /dev/null
@@ -0,0 +1,189 @@
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id D23F66DE1AEF\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:11 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id QK8PpjGe__wz for <notmuch@notmuchmail.org>;\r
+ Sun, 31 Jan 2016 12:40:09 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id E7FAD6DE1781\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:08 -0800 (PST)\r
+Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net\r
+ [64.134.185.108])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 39D34F999\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 40ED220C6C; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v3 06/16] Prefer gpg2 in the test suite if available\r
+Date: Sun, 31 Jan 2016 15:39:51 -0500\r
+Message-Id: <1454272801-23623-7-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.7.0.rc3\r
+In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 31 Jan 2016 20:40:12 -0000\r
+\r
+Now that the notmuch client prefers gpg2 if available, having the test\r
+suite use the same preference makes it more likely to validate as\r
+expected.\r
+\r
+Be warned that the final test in T350-crypto.sh fails with an infinite\r
+loop in gpg if you're using an unpatched GnuPG 2.1.10, due to an\r
+upstream GnuPG bug: https://bugs.gnupg.org/gnupg/issue2187.  In\r
+debian, this is resolved in 2.1.10-3\r
+---\r
+ test/README         |  2 +-\r
+ test/T030-config.sh |  2 +-\r
+ test/T040-setup.sh  |  2 +-\r
+ test/T350-crypto.sh | 16 ++++++++--------\r
+ test/test-lib.sh    | 10 +++++++++-\r
+ 5 files changed, 20 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/test/README b/test/README\r
+index e54e36b..9a7e539 100644\r
+--- a/test/README\r
++++ b/test/README\r
+@@ -16,7 +16,7 @@ that you know if you break anything.\r
+   - emacs(1)\r
+   - emacsclient(1)\r
+   - gdb(1)\r
+-  - gpg(1)\r
++  - gpg(1) or gpg2(1)\r
+   - python(1)\r
\r
+ Running Tests\r
+diff --git a/test/T030-config.sh b/test/T030-config.sh\r
+index f404908..daa7b44 100755\r
+--- a/test/T030-config.sh\r
++++ b/test/T030-config.sh\r
+@@ -54,7 +54,7 @@ new.tags=unread;inbox;\r
+ new.ignore=\r
+ search.exclude_tags=\r
+ maildir.synchronize_flags=true\r
+-crypto.gpg_path=gpg\r
++crypto.gpg_path=$GPG\r
+ foo.string=this is another string value\r
+ foo.list=this;is another;list value;"\r
\r
+diff --git a/test/T040-setup.sh b/test/T040-setup.sh\r
+index cf0c00b..9313aec 100755\r
+--- a/test/T040-setup.sh\r
++++ b/test/T040-setup.sh\r
+@@ -29,6 +29,6 @@ new.tags=foo;bar;\r
+ new.ignore=\r
+ search.exclude_tags=baz;\r
+ maildir.synchronize_flags=true\r
+-crypto.gpg_path=gpg"\r
++crypto.gpg_path=$GPG"\r
\r
+ test_done\r
+diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh\r
+index 3656cce..4bc15bc 100755\r
+--- a/test/T350-crypto.sh\r
++++ b/test/T350-crypto.sh\r
+@@ -12,11 +12,11 @@ add_gnupg_home ()\r
+     local output\r
+     [ -d ${GNUPGHOME} ] && return\r
+     mkdir -m 0700 "$GNUPGHOME"\r
+-    gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
++    $GPG --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
+     test_debug "cat $GNUPGHOME/import.log"\r
+-    if (gpg --quick-random --version >/dev/null 2>&1) ; then\r
++    if ($GPG --quick-random --version >/dev/null 2>&1) ; then\r
+       echo quick-random >> "$GNUPGHOME"/gpg.conf\r
+-    elif (gpg --debug-quick-random --version >/dev/null 2>&1) ; then\r
++    elif ($GPG --debug-quick-random --version >/dev/null 2>&1) ; then\r
+       echo debug-quick-random >> "$GNUPGHOME"/gpg.conf\r
+     fi\r
+     echo no-emit-version >> "$GNUPGHOME"/gpg.conf\r
+@@ -26,7 +26,7 @@ add_gnupg_home ()\r
\r
+ add_gnupg_home\r
+ # get key fingerprint\r
+-FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)\r
++FINGERPRINT=$($GPG --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)\r
\r
+ test_expect_success 'emacs delivery of signed message' \\r
+ 'emacs_fcc_message \\r
+@@ -67,8 +67,8 @@ test_expect_equal_json \\r
\r
+ test_begin_subtest "signature verification with full owner trust"\r
+ # give the key full owner trust\r
+-echo "${FINGERPRINT}:6:" | gpg --no-tty --import-ownertrust >>"$GNUPGHOME"/trust.log 2>&1\r
+-gpg --no-tty --check-trustdb >>"$GNUPGHOME"/trust.log 2>&1\r
++echo "${FINGERPRINT}:6:" | $GPG --no-tty --import-ownertrust >>"$GNUPGHOME"/trust.log 2>&1\r
++$GPG --no-tty --check-trustdb >>"$GNUPGHOME"/trust.log 2>&1\r
+ output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
+     | notmuch_json_show_sanitize \\r
+     | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
+@@ -325,8 +325,8 @@ Notmuch Test Suite key revocation (automated) $(date '+%F_%T%z')\r
+ y\r
\r
+ " \\r
+-    | gpg --no-tty --quiet --command-fd 0 --armor --gen-revoke "0x${FINGERPRINT}!" 2>/dev/null \\r
+-    | gpg --no-tty --quiet --import\r
++    | $GPG --no-tty --quiet --command-fd 0 --armor --gen-revoke "0x${FINGERPRINT}!" 2>/dev/null \\r
++    | $GPG --no-tty --quiet --import\r
+ output=$(notmuch show --format=json --verify subject:"test signed message 001" \\r
+     | notmuch_json_show_sanitize \\r
+     | sed -e 's|"created": [1234567890]*|"created": 946728000|')\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index cc08a98..8c1f3c6 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -85,6 +85,13 @@ unset GREP_OPTIONS\r
+ # For emacsclient\r
+ unset ALTERNATE_EDITOR\r
\r
++# choose the preferred GnuPG binary:\r
++if command -v gpg2 > /dev/null; then\r
++    GPG=gpg2\r
++else\r
++    GPG=gpg\r
++fi\r
++\r
+ # Convenience\r
+ #\r
+ # A regexp to match 5 and 40 hexdigits\r
+@@ -1144,6 +1151,7 @@ test_emacs () {\r
+                               $load_emacs_tests \\r
+                               --eval '(setq server-name \"$server_name\")' \\r
+                               --eval '(server-start)' \\r
++                              --eval '(setq epg-gpg-program \"$GPG\")' \\r
+                               --eval '(orphan-watchdog $$)'" || return\r
+               EMACS_SERVER="$server_name"\r
+               # wait until the emacs server is up\r
+@@ -1332,7 +1340,7 @@ test_declare_external_prereq dtach\r
+ test_declare_external_prereq emacs\r
+ test_declare_external_prereq ${TEST_EMACSCLIENT}\r
+ test_declare_external_prereq gdb\r
+-test_declare_external_prereq gpg\r
++test_declare_external_prereq gpg2 || test_declare_external_prereq gpg\r
+ test_declare_external_prereq openssl\r
+ test_declare_external_prereq gpgsm\r
+ test_declare_external_prereq ${NOTMUCH_PYTHON}\r
+-- \r
+2.7.0.rc3\r
+\r