mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tests: Honor environment variable 'TMP'.
This fixes problems with long socket names, e.g. when doing distcheck. * tests/gpgscm/tests.scm (path-join): New function. (with-temporary-working-directory): Honor 'TMP'. (make-temporary-file): Likewise. * tests/migrations/Makefile.am (TMP): Default to '/tmp'. (TESTS_ENVIRONMENT): Set 'TMP'. * tests/openpgp/Makefile.am (TMP): Default to '/tmp'. (TESTS_ENVIRONMENT): Set 'TMP'. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
f26fe4f73e
commit
8270580a5a
@ -160,6 +160,18 @@
|
||||
(sink (open to (logior O_WRONLY O_CREAT) #o600)))
|
||||
(splice source sink)))
|
||||
|
||||
(define (path-join . components)
|
||||
(let loop ((acc #f) (rest (filter (lambda (s)
|
||||
(not (string=? "" s))) components)))
|
||||
(if (null? rest)
|
||||
acc
|
||||
(loop (if (string? acc)
|
||||
(string-append acc "/" (car rest))
|
||||
(car rest))
|
||||
(cdr rest)))))
|
||||
(assert (string=? (path-join "foo" "bar" "baz") "foo/bar/baz"))
|
||||
(assert (string=? (path-join "" "bar" "baz") "bar/baz"))
|
||||
|
||||
(define (canonical-path path)
|
||||
(if (char=? #\/ (string-ref path 0))
|
||||
path
|
||||
@ -222,7 +234,7 @@
|
||||
(macro (with-temporary-working-directory form)
|
||||
(let ((result-sym (gensym)) (cwd-sym (gensym)) (tmp-sym (gensym)))
|
||||
`(let* ((,cwd-sym (getcwd))
|
||||
(,tmp-sym (mkdtemp "gpgscm-XXXXXX"))
|
||||
(,tmp-sym (mkdtemp (path-join (getenv "TMP") "gpgscm-XXXXXX")))
|
||||
(_ (chdir ,tmp-sym))
|
||||
(,result-sym (begin ,@(cdr form))))
|
||||
(chdir ,cwd-sym)
|
||||
@ -230,9 +242,9 @@
|
||||
,result-sym)))
|
||||
|
||||
(define (make-temporary-file . args)
|
||||
(canonical-path (string-append (mkdtemp "gpgscm-XXXXXX")
|
||||
"/"
|
||||
(if (null? args) "a" (car args)))))
|
||||
(canonical-path (path-join
|
||||
(mkdtemp (path-join (getenv "TMP") "gpgscm-XXXXXX"))
|
||||
(if (null? args) "a" (car args)))))
|
||||
|
||||
(define (remove-temporary-file filename)
|
||||
(catch '()
|
||||
|
@ -26,8 +26,11 @@ include $(top_srcdir)/am/cmacros.am
|
||||
|
||||
AM_CFLAGS =
|
||||
|
||||
TMP ?= /tmp
|
||||
|
||||
TESTS_ENVIRONMENT = GPG_AGENT_INFO= LC_ALL=C \
|
||||
PATH=../gpgscm:$(PATH) \
|
||||
TMP=$(TMP) \
|
||||
GPGSCM_PATH=$(top_srcdir)/tests/gpgscm:$(top_srcdir)/tests/migrations
|
||||
|
||||
TESTS = from-classic.scm \
|
||||
|
@ -34,9 +34,12 @@ noinst_PROGRAMS = fake-pinentry
|
||||
|
||||
fake_pinentry_SOURCES = fake-pinentry.c
|
||||
|
||||
TMP ?= /tmp
|
||||
|
||||
TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= LC_ALL=C \
|
||||
EXEEXT=$(EXEEXT) \
|
||||
PATH=../gpgscm:$(PATH) \
|
||||
TMP=$(TMP) \
|
||||
objdir=$(abs_top_builddir) \
|
||||
GPGSCM_PATH=$(top_srcdir)/tests/gpgscm:$(top_srcdir)/tests/openpgp
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user