From 26273db2660c2818fad8c9ad2d88ca2100ee78f0 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Fri, 5 Apr 2013 02:23:35 -0400 Subject: [PATCH] Avoid output in ftp tests. Also add a note explaining why the output is not tested. --- collects/tests/net/ftp.rkt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/collects/tests/net/ftp.rkt b/collects/tests/net/ftp.rkt index fea640bb53..31be61e71c 100644 --- a/collects/tests/net/ftp.rkt +++ b/collects/tests/net/ftp.rkt @@ -22,12 +22,12 @@ (define-values [thd port] (tcp-serve dest text)) (values thd (port->splitstr port))) -(define ((progress-proc dir) get-count) +(define ((progress-proc output dir) get-count) (thread (lambda () (let loop () - (define-values (count changed-evt) (get-count)) - (printf "~a bytes ~aloaded\n" count dir) + (define-values [count changed-evt] (get-count)) + (fprintf output "~a bytes ~aloaded\n" count dir) (sync changed-evt) (loop))))) @@ -51,12 +51,23 @@ (set! conn (ftp-establish-connection server port user passwd)) (ftp-connection? conn) (when (ftp-connection? conn) + (define output (open-output-bytes)) (test (ftp-cd conn "gnu") (for ([f (in-list (ftp-directory-list conn))]) (match-define (list* type ftp-date name ?size) f) (test (ftp-make-file-seconds ftp-date))) - (ftp-download-file conn tmp-dir pth #:progress (progress-proc "down")) - (ftp-upload-file conn (path->string (build-path tmp-dir pth)) #:progress (progress-proc "up")) + (ftp-download-file conn tmp-dir pth + #:progress (progress-proc output "down")) + ;; Note: It would be nice to test the output but there is no + ;; easy way that I see to wait for the progress thread to + ;; finish (it stays alive after the transfer), and it's + ;; probably a bad idea to make a test that expects a specific + ;; output + ;; (get-output-bytes output #t) => #"0 bytes downloaded\n" + ;; (get-output-bytes output #t) => #"744 bytes uploaded\n" + (ftp-upload-file conn (path->string (build-path tmp-dir pth)) + #:progress (progress-proc output "up")) + ;; (get-output-bytes output #t) => #"744 bytes uploaded\n" (ftp-delete-file conn "3dldf/test.file") (ftp-make-directory conn "test") (ftp-delete-directory conn "test")