[Pkg-gnupg-commit] [gnupg2] 63/112: tests: Improve temporary directory handling.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Aug 30 17:48:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit d9240a3a4688c263632b4168ae2e04363bc91a3a
Author: Justus Winter <justus at g10code.com>
Date: Wed Aug 10 11:54:11 2016 +0200
tests: Improve temporary directory handling.
* tests/gpgscm/ffi.c (ffi_init): Rename 'mkdtemp'.
* tests/gpgscm/tests.scm (mkdtemp): New function that uses a sensible
location and template if no arguments are given.
(with-temporary-working-directory): Simplify accordingly.
(make-temporary-file): Likewise.
* tests/openpgp/run-tests.scm (run-tests-parallel-isolated): Likewise.
(run-tests-sequential-isolated): Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgscm/ffi.c | 2 +-
tests/gpgscm/tests.scm | 13 +++++++++++--
tests/openpgp/run-tests.scm | 4 ++--
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index c37bf1d..57de286 100644
--- a/tests/gpgscm/ffi.c
+++ b/tests/gpgscm/ffi.c
@@ -1248,7 +1248,7 @@ ffi_init (scheme *sc, const char *argv0, int argc, const char **argv)
ffi_define_function (sc, open);
ffi_define_function (sc, fdopen);
ffi_define_function (sc, close);
- ffi_define_function (sc, mkdtemp);
+ ffi_define_function_name (sc, "_mkdtemp", mkdtemp);
ffi_define_function (sc, unlink);
ffi_define_function (sc, unlink_recursively);
ffi_define_function (sc, rename);
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index f97b22e..8283eba 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -247,10 +247,19 @@
(chdir ,cwd-sym)
,result-sym)))
+;; Make a temporary directory. If arguments are given, they are
+;; joined using path-join, and must end in a component ending in
+;; "XXXXXX". If no arguments are given, a suitable location and
+;; generic name is used.
+(define (mkdtemp . components)
+ (_mkdtemp (if (null? components)
+ (path-join (getenv "TMP") "gpgscm-XXXXXX")
+ (apply path-join components))))
+
(macro (with-temporary-working-directory form)
(let ((result-sym (gensym)) (cwd-sym (gensym)) (tmp-sym (gensym)))
`(let* ((,cwd-sym (getcwd))
- (,tmp-sym (mkdtemp (path-join (getenv "TMP") "gpgscm-XXXXXX")))
+ (,tmp-sym (mkdtemp))
(_ (chdir ,tmp-sym))
(,result-sym (begin ,@(cdr form))))
(chdir ,cwd-sym)
@@ -259,7 +268,7 @@
(define (make-temporary-file . args)
(canonical-path (path-join
- (mkdtemp (path-join (getenv "TMP") "gpgscm-XXXXXX"))
+ (mkdtemp)
(if (null? args) "a" (car args)))))
(define (remove-temporary-file filename)
diff --git a/tests/openpgp/run-tests.scm b/tests/openpgp/run-tests.scm
index 367c641..e3b6b6a 100644
--- a/tests/openpgp/run-tests.scm
+++ b/tests/openpgp/run-tests.scm
@@ -128,7 +128,7 @@
(unlink-recursively t::directory)
(t::report)) results::procs)
(exit (results::report)))
- (let* ((wd (mkdtemp "gpgscm-XXXXXX"))
+ (let* ((wd (mkdtemp))
(test (car tests'))
(test' (test::set-directory wd))
(setup' (setup::set-directory wd)))
@@ -154,7 +154,7 @@
(unlink-recursively t::directory))
results::procs)
(exit (results::report)))
- (let* ((wd (mkdtemp "gpgscm-XXXXXX"))
+ (let* ((wd (mkdtemp))
(test (car tests'))
(test' (test::set-directory wd))
(setup' (setup::set-directory wd)))
--
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