changing tests for environments where listen fails

original commit: 09dd60789a
This commit is contained in:
Jay McCarthy 2012-10-19 15:24:20 -06:00
parent d9f2ed0abc
commit eeace01d3b

View File

@ -67,31 +67,27 @@
=> #"fQJ,fN/4F4!~K~MH" => #"fQJ,fN/4F4!~K~MH"
(local [(define (test-echo-server) (local [(define (test-echo-server)
(define conn #f)
(define r (number->string (random 1000))) (define r (number->string (random 1000)))
(define shutdown! #f)
(define p #f)
(define confirm (make-async-channel)) (define confirm (make-async-channel))
(test (set! shutdown! (define shutdown!
(ws-serve #:port 0 (ws-serve #:port 0
#:confirmation-channel confirm #:confirmation-channel confirm
(λ (wsc _) (λ (wsc _)
(let loop () (let loop ()
(define m (ws-recv wsc)) (define m (ws-recv wsc))
(unless (eof-object? m) (unless (eof-object? m)
(ws-send! wsc m) (ws-send! wsc m)
(loop)))))) (loop))))))
shutdown! (define p (async-channel-get confirm))
(set! p (async-channel-get confirm)) (define conn
p (ws-connect (string->url (format "ws://localhost:~a" p))))
(set! conn (ws-connect (string->url (format "ws://localhost:~a" p)))) (when conn
conn (test (ws-send! conn r)
(ws-send! conn r) (ws-recv conn) => r
(ws-recv conn) => r (ws-send! conn "a")
(ws-send! conn "a") (ws-recv conn) => "a"
(ws-recv conn) => "a" (ws-close! conn)))
(ws-close! conn) (test (shutdown!)))]
(shutdown!)))]
(test #:failure-prefix "old" (test #:failure-prefix "old"
(parameterize ([framing-mode 'old]) (test-echo-server)) (parameterize ([framing-mode 'old]) (test-echo-server))
#:failure-prefix "new" #:failure-prefix "new"