summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/publish.scm41
1 files changed, 34 insertions, 7 deletions
diff --git a/tests/publish.scm b/tests/publish.scm
index 4dc807505c..0fd3b50ecb 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -66,16 +66,28 @@
(lambda ()
(http-get uri #:port socket #:streaming? #t))
(lambda (response port)
- (setvbuf port _IONBF)
+ ;; Don't (setvbuf port _IONBF) because of <http://bugs.gnu.org/19610>
+ ;; (PORT might be a custom binary input port).
port))))
(define (publish-uri 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.
-(call-with-new-thread
- (lambda ()
- (guix-publish "--port=6789" "-C0"))) ;attempt to avoid port collision
+(with-separate-output-ports
+ (call-with-new-thread
+ (lambda ()
+ (guix-publish "--port=6789" "-C0")))) ;attempt to avoid port collision
(define (wait-until-ready port)
;; Wait until the server is accepting connections.
@@ -185,9 +197,10 @@ References: ~%"
`(("StorePath" . ,%item)
("URL" . ,(string-append "nar/gzip/" (basename %item)))
("Compression" . "gzip"))
- (let ((thread (call-with-new-thread
- (lambda ()
- (guix-publish "--port=6799" "-C5")))))
+ (let ((thread (with-separate-output-ports
+ (call-with-new-thread
+ (lambda ()
+ (guix-publish "--port=6799" "-C5"))))))
(wait-until-ready 6799)
(let* ((url (string-append "http://localhost:6799/"
(store-path-hash-part %item) ".narinfo"))
@@ -200,6 +213,20 @@ References: ~%"
(_ #f)))
(recutils->alist body)))))
+(unless (zlib-available?)
+ (test-skip 1))
+(test-equal "/*.narinfo for a compressed file"
+ '("none" "nar") ;compression-less nar
+ ;; Assume 'guix publish -C' is already running on port 6799.
+ (let* ((item (add-text-to-store %store "fake.tar.gz"
+ "This is a fake compressed file."))
+ (url (string-append "http://localhost:6799/"
+ (store-path-hash-part item) ".narinfo"))
+ (body (http-get-port url))
+ (info (recutils->alist body)))
+ (list (assoc-ref info "Compression")
+ (dirname (assoc-ref info "URL")))))
+
(test-equal "/nar/ with properly encoded '+' sign"
"Congrats!"
(let ((item (add-text-to-store %store "fake-gtk+" "Congrats!")))