Skip to content

Commit 90d4a61

Browse files
Bogdanpjeapostrophe
authored andcommitted
test,gh3: disable test for old versions of Racket
Also, adjust the test to use serve to avoid needing to parse the output port to get the server's listening port.
1 parent 3e0e089 commit 90d4a61

File tree

1 file changed

+38
-31
lines changed
  • web-server-test/tests/web-server/pr/gh3

1 file changed

+38
-31
lines changed
Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
#lang racket/base
2-
(require racket/runtime-path
2+
3+
(require net/http-client
4+
racket/async-channel
35
racket/port
4-
racket/list
5-
web-server/servlet
6-
net/http-client
7-
web-server/servlet-env)
6+
racket/runtime-path
7+
version/utils
8+
web-server/http
9+
web-server/servlet-dispatch
10+
web-server/web-server)
811

9-
(define-runtime-path here ".")
12+
(define-runtime-path private-key.pem
13+
"private-key.pem")
14+
(define-runtime-path server-cert.pem
15+
"server-cert.pem")
1016

1117
(module+ test
1218
(require rackunit)
13-
14-
(define-values (pipe-i pipe-o) (make-pipe))
15-
16-
(define server-t
17-
(parameterize ([current-output-port pipe-o])
18-
(thread
19-
(λ ()
20-
(serve/servlet (lambda (req) (response/xexpr `(html (body (h1 "Hello")))))
21-
#:launch-browser? #f
22-
#:port 0
23-
#:listen-ip #f
24-
#:ssl? #t
25-
#:ssl-cert (build-path here "server-cert.pem")
26-
#:ssl-key (build-path here "private-key.pem")
27-
#:servlet-regexp #rx"")))))
2819

29-
(define the-port
30-
(string->number
31-
(second
32-
(regexp-match #rx"localhost:([0-9]+).$" (read-line pipe-i)))))
33-
34-
(define-values (status headers body)
35-
(http-sendrecv "localhost" "/" #:port the-port #:ssl? #t))
36-
37-
(check-equal? status #"HTTP/1.1 200 OK")
38-
(check-equal? (port->bytes body) #"<html><body><h1>Hello</h1></body></html>"))
20+
;; Old versions of Racket don't work well with recent versions of
21+
;; OpenSSL found in CI. So, skip this test for older Rackets.
22+
(unless (version<? (version) "8.16")
23+
(define ssl-connect@
24+
(make-ssl-connect@ server-cert.pem private-key.pem))
25+
(define confirmation-ch
26+
(make-async-channel))
27+
(define stop
28+
(serve
29+
#:dispatch
30+
(dispatch/servlet
31+
(lambda (_req)
32+
(response/xexpr `(html (body (h1 "Hello"))))))
33+
#:port 0
34+
#:confirmation-channel confirmation-ch
35+
#:dispatch-server-connect@ ssl-connect@))
36+
(define port
37+
(sync confirmation-ch))
38+
(when (exn:fail? port)
39+
(raise port))
40+
(test-case "regression test for GH issue #3"
41+
(define-values (status _headers body)
42+
(http-sendrecv "localhost" "/" #:port port #:ssl? #t))
43+
(check-equal? status #"HTTP/1.1 200 OK")
44+
(check-equal? (port->bytes body) #"<html><body><h1>Hello</h1></body></html>"))
45+
(stop)))

0 commit comments

Comments
 (0)