mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
tests: Make sure threads use separate output ports.
* tests/publish.scm (with-separate-output-ports): New macro. <top level>: Use it when spawning new thread. ("/*.narinfo with compression"): Likewise.
This commit is contained in:
parent
2c7b48c2fb
commit
a5c376034f
1 changed files with 18 additions and 6 deletions
|
@ -73,10 +73,21 @@ (define (http-get-port uri)
|
||||||
(define (publish-uri route)
|
(define (publish-uri route)
|
||||||
(string-append "http://localhost:6789" route))
|
(string-append "http://localhost:6789" route))
|
||||||
|
|
||||||
|
(define-syntax-rule (with-separate-output-ports exp ...)
|
||||||
|
;; Since ports aren't thread-safe in Guile 2.0, duplicate the output and
|
||||||
|
;; error ports to make sure the two threads don't end up stepping on each
|
||||||
|
;; other's toes.
|
||||||
|
(with-output-to-port (duplicate-port (current-output-port) "w")
|
||||||
|
(lambda ()
|
||||||
|
(with-error-to-port (duplicate-port (current-error-port) "w")
|
||||||
|
(lambda ()
|
||||||
|
exp ...)))))
|
||||||
|
|
||||||
;; Run a local publishing server in a separate thread.
|
;; Run a local publishing server in a separate thread.
|
||||||
(call-with-new-thread
|
(with-separate-output-ports
|
||||||
(lambda ()
|
(call-with-new-thread
|
||||||
(guix-publish "--port=6789" "-C0"))) ;attempt to avoid port collision
|
(lambda ()
|
||||||
|
(guix-publish "--port=6789" "-C0")))) ;attempt to avoid port collision
|
||||||
|
|
||||||
(define (wait-until-ready port)
|
(define (wait-until-ready port)
|
||||||
;; Wait until the server is accepting connections.
|
;; Wait until the server is accepting connections.
|
||||||
|
@ -186,9 +197,10 @@ (define (wait-until-ready port)
|
||||||
`(("StorePath" . ,%item)
|
`(("StorePath" . ,%item)
|
||||||
("URL" . ,(string-append "nar/gzip/" (basename %item)))
|
("URL" . ,(string-append "nar/gzip/" (basename %item)))
|
||||||
("Compression" . "gzip"))
|
("Compression" . "gzip"))
|
||||||
(let ((thread (call-with-new-thread
|
(let ((thread (with-separate-output-ports
|
||||||
(lambda ()
|
(call-with-new-thread
|
||||||
(guix-publish "--port=6799" "-C5")))))
|
(lambda ()
|
||||||
|
(guix-publish "--port=6799" "-C5"))))))
|
||||||
(wait-until-ready 6799)
|
(wait-until-ready 6799)
|
||||||
(let* ((url (string-append "http://localhost:6799/"
|
(let* ((url (string-append "http://localhost:6799/"
|
||||||
(store-path-hash-part %item) ".narinfo"))
|
(store-path-hash-part %item) ".narinfo"))
|
||||||
|
|
Loading…
Reference in a new issue