|
5 | 5 | racket/port |
6 | 6 | racket/promise |
7 | 7 | rackunit |
| 8 | + version/utils |
8 | 9 | web-server/http |
9 | 10 | web-server/safety-limits |
10 | 11 | web-server/servlet-dispatch |
|
107 | 108 | (http-conn-close! hc))) |
108 | 109 | (check-duration stop 1 3 5)))) |
109 | 110 |
|
110 | | - (test-case "kills the server if stop is called twice" |
111 | | - (define started?-sema |
112 | | - (make-semaphore)) |
113 | | - (call-with-web-server |
114 | | - (lambda (_req) |
115 | | - (response/output |
116 | | - (lambda (out) |
117 | | - (displayln "start" out) |
118 | | - (semaphore-post started?-sema) |
119 | | - (sleep 100) |
120 | | - (displayln "end" out)))) |
121 | | - (lambda (port stop) |
122 | | - (define hc (http-conn-open "127.0.0.1" #:port port)) |
123 | | - (define-values (status _headers in) |
124 | | - (http-conn-sendrecv! hc "/")) |
125 | | - (check-equal? status #"HTTP/1.1 200 OK") |
126 | | - (define data-promise |
127 | | - (delay/thread |
128 | | - (port->bytes in))) |
129 | | - (semaphore-wait started?-sema) |
130 | | - (define stop-thds |
131 | | - (for/list ([_ (in-range 2)]) |
132 | | - (thread stop))) |
133 | | - (check-duration |
134 | | - (lambda () |
135 | | - (for-each thread-wait stop-thds)) |
136 | | - 0 1 2) |
137 | | - (check-equal? |
138 | | - (force data-promise) |
139 | | - #"start\n"))))))) |
| 111 | + ;; On versions prior to [1], net/http-client writes to standard |
| 112 | + ;; error when reading from the connection's input port goes wrong. |
| 113 | + ;; This makes raco test fail in --drdr mode, so avoid running this |
| 114 | + ;; test on versions before 8.17.0.6. |
| 115 | + ;; |
| 116 | + ;; [1]: https://github.com/racket/racket/pull/5296 |
| 117 | + (when (version<=? "8.17.0.6" (version)) |
| 118 | + (test-case "kills the server if stop is called twice" |
| 119 | + (define started?-sema |
| 120 | + (make-semaphore)) |
| 121 | + (call-with-web-server |
| 122 | + (lambda (_req) |
| 123 | + (response/output |
| 124 | + (lambda (out) |
| 125 | + (displayln "start" out) |
| 126 | + (semaphore-post started?-sema) |
| 127 | + (sleep 100) |
| 128 | + (displayln "end" out)))) |
| 129 | + (lambda (port stop) |
| 130 | + (define hc (http-conn-open "127.0.0.1" #:port port)) |
| 131 | + (define-values (status _headers in) |
| 132 | + (http-conn-sendrecv! hc "/")) |
| 133 | + (check-equal? status #"HTTP/1.1 200 OK") |
| 134 | + (define data-promise |
| 135 | + (delay/thread |
| 136 | + (with-handlers ([(lambda (e) |
| 137 | + (and (exn:fail? e) |
| 138 | + (regexp-match? #rx"input port is closed" (exn-message e)))) |
| 139 | + (lambda (_) |
| 140 | + #"")]) |
| 141 | + (port->bytes in)))) |
| 142 | + (semaphore-wait started?-sema) |
| 143 | + (define stop-thds |
| 144 | + (for/list ([_ (in-range 2)]) |
| 145 | + (thread stop))) |
| 146 | + (check-duration |
| 147 | + (lambda () |
| 148 | + (for-each thread-wait stop-thds)) |
| 149 | + 0 1 2) |
| 150 | + (check-match |
| 151 | + (force data-promise) |
| 152 | + (or #"" #"start\n"))))))))) |
140 | 153 |
|
141 | 154 | (module+ test |
142 | 155 | (require rackunit/text-ui) |
|
0 commit comments