tests: Add macro managing ephemeral home directories.
authorJustus Winter <justus@g10code.com>
Tue, 20 Dec 2016 15:24:12 +0000 (16:24 +0100)
committerJustus Winter <justus@g10code.com>
Tue, 20 Dec 2016 15:49:05 +0000 (16:49 +0100)
* tests/openpgp/defs.scm (with-ephemeral-home-directory): New macro.
* tests/openpgp/setup.scm: Use the new macro.

tests/openpgp/defs.scm
tests/openpgp/setup.scm

index 8111f0f..3280d7c 100644 (file)
 ;; 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.
index fc0615f..abe1157 100755 (executable)
@@ -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)