diff options
author | Rob Browning <rlb@defaultvalue.org> | 2020-01-22 21:23:16 -0600 |
---|---|---|
committer | Rob Browning <rlb@defaultvalue.org> | 2020-01-22 21:23:16 -0600 |
commit | 9a11be136f8509ec09227866414abfed25894910 (patch) | |
tree | 2c01b50c2e907436ac2ca14f87437188c07759f0 /test-suite | |
parent | 5d2956497137c2f7453e21d334d152bfd91a3ef8 (diff) |
00-repl-server.test: don't use fixed path for socket
* test-suite/tests/00-repl-server.test (make-tempdir): Add.
(call-with-repl-server): Store socket in a make-tempdir dir.
Diffstat (limited to 'test-suite')
-rw-r--r-- | test-suite/tests/00-repl-server.test | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test-suite/tests/00-repl-server.test b/test-suite/tests/00-repl-server.test index 54f518a66..ebc2cad11 100644 --- a/test-suite/tests/00-repl-server.test +++ b/test-suite/tests/00-repl-server.test @@ -24,13 +24,26 @@ #:use-module (web request) #:use-module (test-suite lib)) +;; FIXME: replace with mkdtemp! (or equivalent) when available +(define (make-tempdir) + (let loop ((try 0) + (n (random:uniform))) + (let* ((path (string-append "/tmp/repl-server-test-" (number->string n))) + (dir (false-if-exception (mkdir path #o700)))) + (cond + (dir path) + ((> try 10) + (error "Unable to create directory in /tmp for 00-repl-server.test")) + (else (loop (1+ try) (random:uniform))))))) + (define (call-with-repl-server proc) "Set up a REPL server in a separate process and call PROC with a socket connected to that server." - (let ((sockaddr (make-socket-address AF_UNIX "/tmp/repl-server")) - (client-socket (socket AF_UNIX SOCK_STREAM 0))) - (false-if-exception - (delete-file (sockaddr:path sockaddr))) + (let* ((tmpdir (make-tempdir)) + (sockaddr (make-socket-address AF_UNIX (string-append tmpdir "/repl-server"))) + (client-socket (socket AF_UNIX SOCK_STREAM 0))) + (false-if-exception (delete-file (sockaddr:path sockaddr))) + (false-if-exception (rmdir tmpdir)) ;; The REPL server requires thread. The test requires fork. (unless (and (provided? 'threads) (provided? 'fork)) |