1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-17 17:58:46 +00:00

Don't test symmetric operations on gpg 2.0 (Bug#23561)

On the Hydra test machines, which have gpg 2.0, the symmetric tests
fail.
* test/lisp/epg-tests.el (with-epg-tests): Pass REQUIRE-PUBLIC-KEY to
`epg-tests-find-usable-gpg-configuration' and call it before
`epg-make-context' so that the latter uses the resulting cached
config.
(epg-tests-find-usable-gpg-configuration): Only allow gpg 2.0 for
symmetric operations.  Clear `epg--configurations' and don't pass
NO-CACHE to `epg-find-configuration'.
(epg-tests--config-program-alist): Use copy-tree to avoid modifying
the epg-config--program-alist cons values.
* test/lisp/emacs-lisp/package-tests.el (package-test-signed): Allow
running with gpg 2.0.
This commit is contained in:
Noam Postavsky 2018-07-15 09:37:59 -04:00
parent 95931085fa
commit 7acb87ab97
2 changed files with 31 additions and 14 deletions

View File

@ -473,7 +473,17 @@ Must called from within a `tar-mode' buffer."
(let ((process-environment
(cons (concat "HOME=" homedir)
process-environment)))
(epg-find-configuration 'OpenPGP))
(epg-find-configuration
'OpenPGP nil
;; By default we require gpg2 2.1+ due to some
;; practical problems with pinentry. But this
;; test works fine with 2.0 as well.
(let ((prog-alist (copy-tree epg-config--program-alist)))
(setf (alist-get "gpg2"
(alist-get 'OpenPGP prog-alist)
nil nil #'equal)
"2.0")
prog-alist)))
(delete-directory homedir t))))
(let* ((keyring (expand-file-name "key.pub" package-test-data-dir))
(package-test-data-dir

View File

@ -33,17 +33,26 @@
(defconst epg-tests--config-program-alist
;; The default `epg-config--program-alist' requires gpg2 2.1 or
;; greater due to some practical problems with pinentry. But the
;; tests here all work fine with 2.0 as well.
(let ((prog-alist (copy-sequence epg-config--program-alist)))
;; greater due to some practical problems with pinentry. But most
;; tests here work fine with 2.0 as well.
(let ((prog-alist (copy-tree epg-config--program-alist)))
(setf (alist-get "gpg2"
(alist-get 'OpenPGP prog-alist)
nil nil #'equal)
"2.0")
prog-alist))
(defun epg-tests-find-usable-gpg-configuration (&optional _require-passphrase)
(epg-find-configuration 'OpenPGP 'no-cache epg-tests--config-program-alist))
(defun epg-tests-find-usable-gpg-configuration
(&optional require-passphrase require-public-key)
;; Clear config cache because we may be using a different
;; program-alist. We do want to update the cache, so that
;; `epg-make-context' can use our result.
(setq epg--configurations nil)
(epg-find-configuration 'OpenPGP nil
;; The symmetric operations fail on Hydra
;; with gpg 2.0.
(if (or (not require-passphrase) require-public-key)
epg-tests--config-program-alist)))
(defun epg-tests-passphrase-callback (_c _k _d)
;; Need to create a copy here, since the string will be wiped out
@ -63,14 +72,12 @@
(format "GNUPGHOME=%s" epg-tests-home-directory))
process-environment)))
(unwind-protect
(let ((context (epg-make-context 'OpenPGP))
(epg-config (epg-tests-find-usable-gpg-configuration
,(if require-passphrase
`'require-passphrase))))
;; GNUPGHOME is needed to find a usable gpg, so we can't
;; check whether to skip any earlier (Bug#23561).
(unless epg-config
(ert-skip "No usable gpg config"))
;; GNUPGHOME is needed to find a usable gpg, so we can't
;; check whether to skip any earlier (Bug#23561).
(let ((epg-config (or (epg-tests-find-usable-gpg-configuration
,require-passphrase ,require-public-key)
(ert-skip "No usable gpg config")))
(context (epg-make-context 'OpenPGP)))
(setf (epg-context-program context)
(alist-get 'program epg-config))
(setf (epg-context-home-directory context)