mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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>
This commit is contained in:
parent
efe973dab7
commit
d9240a3a46
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user