aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-12-20 15:24:12 +0000
committerJustus Winter <[email protected]>2016-12-20 15:49:05 +0000
commitc067a012c764218b94ce8de2914615a895a75f3e (patch)
tree39c6d4fb93bd631e8351462349697b4887726d31
parenttests: Move argument parser. (diff)
downloadgnupg-c067a012c764218b94ce8de2914615a895a75f3e.tar.gz
gnupg-c067a012c764218b94ce8de2914615a895a75f3e.zip
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.
-rw-r--r--tests/openpgp/defs.scm11
-rwxr-xr-xtests/openpgp/setup.scm3
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 8111f0fe5..3280d7cd4 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 fc0615fc8..abe1157e8 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)