[Pkg-gnupg-commit] [gnupg2] 115/160: tests: Honor environment variable 'TMP'.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Jul 15 09:36:42 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch upstream
in repository gnupg2.

commit 8270580a5a70874beeffcdd16221937db4bcdc93
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jul 5 16:25:21 2016 +0200

    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 at g10code.com>
---
 tests/gpgscm/tests.scm       | 20 ++++++++++++++++----
 tests/migrations/Makefile.am |  3 +++
 tests/openpgp/Makefile.am    |  3 +++
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index ebe1be5..2728817 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -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 '()
diff --git a/tests/migrations/Makefile.am b/tests/migrations/Makefile.am
index 0377b23..9c82d66 100644
--- a/tests/migrations/Makefile.am
+++ b/tests/migrations/Makefile.am
@@ -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 \
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index 4137018..012a3f2 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -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
 

-- 
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