[Pkg-gnupg-commit] [gnupg2] 35/116: tests: Fix macro.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Jan 24 04:40:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 4ded213698123a425393b89a800fda2a4ec5229d
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jan 5 17:00:36 2017 +0100

    tests: Fix macro.
    
    * tests/openpgp/defs.scm (with-ephemeral-home-directory): Make
    hygienic, use define-macro, do not change to the ephemeral home
    directory.
    * tests/gpgsm/setup.scm: Change to the ephemeral home directory.
    * tests/openpgp/setup.scm: Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgsm/setup.scm   |  1 +
 tests/openpgp/defs.scm  | 18 ++++++++++--------
 tests/openpgp/setup.scm |  1 +
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/gpgsm/setup.scm b/tests/gpgsm/setup.scm
index fdf277d..91821a0 100644
--- a/tests/gpgsm/setup.scm
+++ b/tests/gpgsm/setup.scm
@@ -24,6 +24,7 @@
 	(error "Usage: setup.scm --create-tarball <file> ..."))
 
 (with-ephemeral-home-directory
+ (chdir (getenv "GNUPGHOME"))
  (create-gpgsmhome)
  (stop-agent)
  (call-check `(,(tool 'gpgtar) --create --output ,(car tarball) ".")))
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 863d128..837e096 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -222,14 +222,16 @@
 
 ;; Evaluate a sequence of expressions with an ephemeral home
 ;; directory.
-(macro (with-ephemeral-home-directory form)
-  `(let ((original-home-directory (getenv "GNUPGHOME")))
-     (with-temporary-working-directory
-      (define ephemeral-home-directory (getcwd))
-      (dynamic-wind
-	  (lambda () (setenv "GNUPGHOME" ephemeral-home-directory #t))
-	  (lambda () ,@(cdr form))
-	  (lambda () (setenv "GNUPGHOME" original-home-directory #t))))))
+(define-macro (with-ephemeral-home-directory . expressions)
+  (let ((original-home-directory (gensym))
+	(ephemeral-home-directory (gensym)))
+    `(let ((,original-home-directory (getenv "GNUPGHOME"))
+	   (,ephemeral-home-directory (mkdtemp)))
+       (finally (unlink-recursively ,ephemeral-home-directory)
+	 (dynamic-wind
+	     (lambda () (setenv "GNUPGHOME" ,ephemeral-home-directory #t))
+	     (lambda () , at expressions)
+	     (lambda () (setenv "GNUPGHOME" ,original-home-directory #t)))))))
 
 ;; Call GPG to obtain the hash sums.  Either specify an input file in
 ;; ARGS, or an string in INPUT.  Returns a list of (<algo>
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index abe1157..d13799d 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -23,6 +23,7 @@
 	(fail "Usage: setup.scm --create-tarball <file>"))
 
 (with-ephemeral-home-directory
+ (chdir (getenv "GNUPGHOME"))
  (create-gpghome)
  (create-legacy-gpghome)
  (stop-agent)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list