diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-10-12 23:19:09 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-10-12 23:47:48 +0200 |
commit | 6ea10db973d861cd8774938e40151c0f8b2d266f (patch) | |
tree | d86b6ca502a946097c2a610158fbad4caa91260e /tests | |
parent | e37415917c4758142c052cae46b3d84517b54ec2 (diff) | |
download | patches-6ea10db973d861cd8774938e40151c0f8b2d266f.tar patches-6ea10db973d861cd8774938e40151c0f8b2d266f.tar.gz |
tests: Support multiple HTTP server instances.
* guix/tests/http.scm (%http-server-socket): Turn into...
(open-http-server-socket): ... this procedure.
(http-server-can-listen?): New procedure.
(http-write, %http-server-lock, %http-server-ready)
(http-open, stub-http-server): Move to 'call-with-http-server' body.
(call-with-http-server): Add #:headers parameter.
(with-http-server): Add an additional pattern with headers.
* tests/derivations.scm: Use (http-server-can-listen?) instead
of (force %http-server-socket).
* tests/lint.scm: Likewise.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/derivations.scm | 8 | ||||
-rw-r--r-- | tests/lint.scm | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm index f3aad1b906..36afd42d05 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -222,7 +222,7 @@ (build-derivations %store (list drv)) #f))) -(unless (force %http-server-socket) +(unless (http-server-can-listen?) (test-skip 1)) (test-assert "'download' built-in builder" (let ((text (random-text))) @@ -238,7 +238,7 @@ get-string-all) text)))))) -(unless (force %http-server-socket) +(unless (http-server-can-listen?) (test-skip 1)) (test-assert "'download' built-in builder, invalid hash" (with-http-server 200 "hello, world!" @@ -253,7 +253,7 @@ (build-derivations %store (list drv)) #f)))) -(unless (force %http-server-socket) +(unless (http-server-can-listen?) (test-skip 1)) (test-assert "'download' built-in builder, not found" (with-http-server 404 "not found" @@ -279,7 +279,7 @@ (build-derivations %store (list drv)) #f))) -(unless (force %http-server-socket) +(unless (http-server-can-listen?) (test-skip 1)) (test-assert "'download' built-in builder, check mode" ;; Make sure rebuilding the 'builtin:download' derivation in check mode diff --git a/tests/lint.scm b/tests/lint.scm index 7610a91fd3..d7254bc070 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -388,7 +388,7 @@ (check-home-page pkg))) "domain not found"))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "home-page: Connection refused" (->bool (string-contains @@ -399,7 +399,7 @@ (check-home-page pkg))) "Connection refused"))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "home-page: 200" "" (with-warnings @@ -409,7 +409,7 @@ (home-page (%local-url))))) (check-home-page pkg))))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "home-page: 200 but short length" (->bool (string-contains @@ -421,7 +421,7 @@ (check-home-page pkg)))) "suspiciously small"))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "home-page: 404" (->bool (string-contains @@ -510,7 +510,7 @@ (check-source-file-name pkg))) "file name should contain the package name")))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "source: 200" "" (with-warnings @@ -523,7 +523,7 @@ (sha256 %null-sha256)))))) (check-source pkg))))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "source: 200 but short length" (->bool (string-contains @@ -538,7 +538,7 @@ (check-source pkg)))) "suspiciously small"))) -(test-skip (if (force %http-server-socket) 0 1)) +(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "source: 404" (->bool (string-contains |