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) | |
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 f3aad1b9067..36afd42d05c 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm | |||
| @@ -222,7 +222,7 @@ | |||
| 222 | (build-derivations %store (list drv)) | 222 | (build-derivations %store (list drv)) |
| 223 | #f))) | 223 | #f))) |
| 224 | 224 | ||
| 225 | (unless (force %http-server-socket) | 225 | (unless (http-server-can-listen?) |
| 226 | (test-skip 1)) | 226 | (test-skip 1)) |
| 227 | (test-assert "'download' built-in builder" | 227 | (test-assert "'download' built-in builder" |
| 228 | (let ((text (random-text))) | 228 | (let ((text (random-text))) |
| @@ -238,7 +238,7 @@ | |||
| 238 | get-string-all) | 238 | get-string-all) |
| 239 | text)))))) | 239 | text)))))) |
| 240 | 240 | ||
| 241 | (unless (force %http-server-socket) | 241 | (unless (http-server-can-listen?) |
| 242 | (test-skip 1)) | 242 | (test-skip 1)) |
| 243 | (test-assert "'download' built-in builder, invalid hash" | 243 | (test-assert "'download' built-in builder, invalid hash" |
| 244 | (with-http-server 200 "hello, world!" | 244 | (with-http-server 200 "hello, world!" |
| @@ -253,7 +253,7 @@ | |||
| 253 | (build-derivations %store (list drv)) | 253 | (build-derivations %store (list drv)) |
| 254 | #f)))) | 254 | #f)))) |
| 255 | 255 | ||
| 256 | (unless (force %http-server-socket) | 256 | (unless (http-server-can-listen?) |
| 257 | (test-skip 1)) | 257 | (test-skip 1)) |
| 258 | (test-assert "'download' built-in builder, not found" | 258 | (test-assert "'download' built-in builder, not found" |
| 259 | (with-http-server 404 "not found" | 259 | (with-http-server 404 "not found" |
| @@ -279,7 +279,7 @@ | |||
| 279 | (build-derivations %store (list drv)) | 279 | (build-derivations %store (list drv)) |
| 280 | #f))) | 280 | #f))) |
| 281 | 281 | ||
| 282 | (unless (force %http-server-socket) | 282 | (unless (http-server-can-listen?) |
| 283 | (test-skip 1)) | 283 | (test-skip 1)) |
| 284 | (test-assert "'download' built-in builder, check mode" | 284 | (test-assert "'download' built-in builder, check mode" |
| 285 | ;; Make sure rebuilding the 'builtin:download' derivation in check mode | 285 | ;; Make sure rebuilding the 'builtin:download' derivation in check mode |
diff --git a/tests/lint.scm b/tests/lint.scm index 7610a91fd3b..d7254bc070d 100644 --- a/tests/lint.scm +++ b/tests/lint.scm | |||
| @@ -388,7 +388,7 @@ | |||
| 388 | (check-home-page pkg))) | 388 | (check-home-page pkg))) |
| 389 | "domain not found"))) | 389 | "domain not found"))) |
| 390 | 390 | ||
| 391 | (test-skip (if (force %http-server-socket) 0 1)) | 391 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 392 | (test-assert "home-page: Connection refused" | 392 | (test-assert "home-page: Connection refused" |
| 393 | (->bool | 393 | (->bool |
| 394 | (string-contains | 394 | (string-contains |
| @@ -399,7 +399,7 @@ | |||
| 399 | (check-home-page pkg))) | 399 | (check-home-page pkg))) |
| 400 | "Connection refused"))) | 400 | "Connection refused"))) |
| 401 | 401 | ||
| 402 | (test-skip (if (force %http-server-socket) 0 1)) | 402 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 403 | (test-equal "home-page: 200" | 403 | (test-equal "home-page: 200" |
| 404 | "" | 404 | "" |
| 405 | (with-warnings | 405 | (with-warnings |
| @@ -409,7 +409,7 @@ | |||
| 409 | (home-page (%local-url))))) | 409 | (home-page (%local-url))))) |
| 410 | (check-home-page pkg))))) | 410 | (check-home-page pkg))))) |
| 411 | 411 | ||
| 412 | (test-skip (if (force %http-server-socket) 0 1)) | 412 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 413 | (test-assert "home-page: 200 but short length" | 413 | (test-assert "home-page: 200 but short length" |
| 414 | (->bool | 414 | (->bool |
| 415 | (string-contains | 415 | (string-contains |
| @@ -421,7 +421,7 @@ | |||
| 421 | (check-home-page pkg)))) | 421 | (check-home-page pkg)))) |
| 422 | "suspiciously small"))) | 422 | "suspiciously small"))) |
| 423 | 423 | ||
| 424 | (test-skip (if (force %http-server-socket) 0 1)) | 424 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 425 | (test-assert "home-page: 404" | 425 | (test-assert "home-page: 404" |
| 426 | (->bool | 426 | (->bool |
| 427 | (string-contains | 427 | (string-contains |
| @@ -510,7 +510,7 @@ | |||
| 510 | (check-source-file-name pkg))) | 510 | (check-source-file-name pkg))) |
| 511 | "file name should contain the package name")))) | 511 | "file name should contain the package name")))) |
| 512 | 512 | ||
| 513 | (test-skip (if (force %http-server-socket) 0 1)) | 513 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 514 | (test-equal "source: 200" | 514 | (test-equal "source: 200" |
| 515 | "" | 515 | "" |
| 516 | (with-warnings | 516 | (with-warnings |
| @@ -523,7 +523,7 @@ | |||
| 523 | (sha256 %null-sha256)))))) | 523 | (sha256 %null-sha256)))))) |
| 524 | (check-source pkg))))) | 524 | (check-source pkg))))) |
| 525 | 525 | ||
| 526 | (test-skip (if (force %http-server-socket) 0 1)) | 526 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 527 | (test-assert "source: 200 but short length" | 527 | (test-assert "source: 200 but short length" |
| 528 | (->bool | 528 | (->bool |
| 529 | (string-contains | 529 | (string-contains |
| @@ -538,7 +538,7 @@ | |||
| 538 | (check-source pkg)))) | 538 | (check-source pkg)))) |
| 539 | "suspiciously small"))) | 539 | "suspiciously small"))) |
| 540 | 540 | ||
| 541 | (test-skip (if (force %http-server-socket) 0 1)) | 541 | (test-skip (if (http-server-can-listen?) 0 1)) |
| 542 | (test-assert "source: 404" | 542 | (test-assert "source: 404" |
| 543 | (->bool | 543 | (->bool |
| 544 | (string-contains | 544 | (string-contains |
