[PATCH v4 06/16] Prefer gpg2 in the test suite if available
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 8 Jul 2016 09:27:17 +0000 (11:27 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:11 +0000 (16:22 -0700)
3e/c33a2e175e93a79d7b2dc7de7521bdc2d647de [new file with mode: 0644]

diff --git a/3e/c33a2e175e93a79d7b2dc7de7521bdc2d647de b/3e/c33a2e175e93a79d7b2dc7de7521bdc2d647de
new file mode 100644 (file)
index 0000000..2295d9a
--- /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 B53966DE02D9\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 03:13:49 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.06\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.06 tagged_above=-999 required=5 tests=[AWL=0.060]\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 jw1BAxRuWCC6 for <notmuch@notmuchmail.org>;\r
+ Fri,  8 Jul 2016 03:13:41 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 4EE826DE0350\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 03:13:12 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [88.128.80.54])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 82B97F99A\r
+ for <notmuch@notmuchmail.org>; Fri,  8 Jul 2016 06:13:11 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 9EF4A211C9; Fri,  8 Jul 2016 11:27:34 +0200 (CEST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v4 06/16] Prefer gpg2 in the test suite if available\r
+Date: Fri,  8 Jul 2016 11:27:17 +0200\r
+Message-Id: <1467970047-8013-7-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467970047-8013-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: Fri, 08 Jul 2016 10:13:49 -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 104a120..b4489da 100644\r
+--- a/test/README\r
++++ b/test/README\r
+@@ -23,7 +23,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
+ If your system lacks these tools or have older, non-upgreable versions\r
+diff --git a/test/T030-config.sh b/test/T030-config.sh\r
+index 0915abd..9eb9294 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
+ built_with.compact=something\r
+diff --git a/test/T040-setup.sh b/test/T040-setup.sh\r
+index 021f2d0..afc7bc0 100755\r
+--- a/test/T040-setup.sh\r
++++ b/test/T040-setup.sh\r
+@@ -29,7 +29,7 @@ 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
+ built_with.compact=something\r
+ built_with.field_processor=something\r
+ built_with.retry_lock=something"\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 aac0343..5c14d1e 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -86,6 +86,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
+@@ -1172,6 +1179,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
+@@ -1368,7 +1376,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.8.1\r
+\r