--- /dev/null
+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 0A1356DE1B24\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:38 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.022\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.022 tagged_above=-999 required=5\r
+ tests=[AWL=-0.022] 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 FrmuX0izMP4v for <notmuch@notmuchmail.org>;\r
+ Tue, 19 Jan 2016 18:53:34 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 6AFDA6DE1A92\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:17 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id CBAB9F98C\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:12 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id E18472050A; Tue, 19 Jan 2016 18:53:10 -0800 (PST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 06/16] Prefer gpg2 in the test suite if available\r
+Date: Tue, 19 Jan 2016 21:52:39 -0500\r
+Message-Id: <1453258369-7366-7-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.7.0.rc3\r
+In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1453258369-7366-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: Wed, 20 Jan 2016 02:53:38 -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 270c718..878b98b 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 hash gpg2 2> /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
+@@ -1139,6 +1146,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
+@@ -1327,5 +1335,5 @@ 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 ${NOTMUCH_PYTHON}\r
+-- \r
+2.7.0.rc3\r
+\r