[Pkg-gnupg-commit] [gnupg2] 04/116: tests: Add macro managing ephemeral home directories.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Jan 24 04:40:48 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 c067a012c764218b94ce8de2914615a895a75f3e
Author: Justus Winter <justus at g10code.com>
Date:   Tue Dec 20 16:24:12 2016 +0100

    tests: Add macro managing ephemeral home directories.
    
    * tests/openpgp/defs.scm (with-ephemeral-home-directory): New macro.
    * tests/openpgp/setup.scm: Use the new macro.
---
 tests/openpgp/defs.scm  | 11 +++++++++++
 tests/openpgp/setup.scm |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 8111f0f..3280d7c 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -200,6 +200,17 @@
 ;; GnuPG helper.
 ;;
 
+;; 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))))))
+
 ;; Call GPG to obtain the hash sums.  Either specify an input file in
 ;; ARGS, or an string in INPUT.  Returns a list of (<algo>
 ;; "<hashsum>") lists.
diff --git a/tests/openpgp/setup.scm b/tests/openpgp/setup.scm
index fc0615f..abe1157 100755
--- a/tests/openpgp/setup.scm
+++ b/tests/openpgp/setup.scm
@@ -22,8 +22,7 @@
 (unless (member "--create-tarball" *args*)
 	(fail "Usage: setup.scm --create-tarball <file>"))
 
-(with-temporary-working-directory
- (setenv "GNUPGHOME" (getcwd) #t)
+(with-ephemeral-home-directory
  (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