summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-08-10 11:54:11 +0200
committerJustus Winter <justus@g10code.com>2016-08-10 11:59:42 +0200
commitd9240a3a4688c263632b4168ae2e04363bc91a3a (patch)
tree5ba18b4d8148d23c3f2494ac5219df0f3528a4c2 /tests
parentgpgscm: Make the name of foreign functions more unique. (diff)
downloadgnupg2-d9240a3a4688c263632b4168ae2e04363bc91a3a.tar.xz
gnupg2-d9240a3a4688c263632b4168ae2e04363bc91a3a.zip
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@g10code.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/gpgscm/ffi.c2
-rw-r--r--tests/gpgscm/tests.scm13
-rw-r--r--tests/openpgp/run-tests.scm4
3 files changed, 14 insertions, 5 deletions
diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index c37bf1daa..57de28614 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 f97b22e66..8283ebad9 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 367c64116..e3b6b6a47 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)))