summaryrefslogtreecommitdiff
path: root/tests/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-05-15 23:40:09 +0200
committerLudovic Courtès <ludo@gnu.org>2013-05-15 23:40:09 +0200
commit101d9f3fd43b436d5dc7ef13e644c7fbbc7f62d5 (patch)
treee3a4eed4c2e50b932d333fa5344d343125c42cfd /tests/utils.scm
parent3d6b71e87eca505262f9756644d72e545c7e48f8 (diff)
substitute-binary: Pass `filtered-port' an unbuffered port.
This fixes a bug whereby `read-response' would read more than just the response, with the extra data going into the port's buffer; the "bzip2 -dc" process spawned by `filtered-port' would not see the those buffered data, which are definitely lost, and would bail out with "bzip2: (stdin) is not a bzip2 file." * guix/utils.scm (filtered-port): Document that INPUT must be unbuffered. * guix/web.scm (http-fetch): Add `buffered?' parameter. Call `open-socket-for-uri' explicitly, and call `setvbuf' when BUFFERED? is false. Pass the port to `http-get'. Close it upon 301/302. * guix/scripts/substitute-binary.scm (fetch): Add `buffered?' parameter. Pass it to `http-fetch'; honor it for `file' URIs. (guix-substitute-binary): Call `fetch' with #:buffered? #f for port RAW. * tests/utils.scm ("filtered-port, file"): Open FILE as unbuffered.
Diffstat (limited to 'tests/utils.scm')
-rw-r--r--tests/utils.scm21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index c2fb2741930..e8549204d07 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -102,17 +102,16 @@
102 list)) 102 list))
103 103
104(test-assert "filtered-port, file" 104(test-assert "filtered-port, file"
105 (let ((file (search-path %load-path "guix.scm"))) 105 (let* ((file (search-path %load-path "guix.scm"))
106 (call-with-input-file file 106 (input (open-file file "r0")))
107 (lambda (input) 107 (let*-values (((compressed pids1)
108 (let*-values (((compressed pids1) 108 (filtered-port `(,%gzip "-c" "--fast") input))
109 (filtered-port `(,%gzip "-c" "--fast") input)) 109 ((decompressed pids2)
110 ((decompressed pids2) 110 (filtered-port `(,%gzip "-d") compressed)))
111 (filtered-port `(,%gzip "-d") compressed))) 111 (and (every (compose zero? cdr waitpid)
112 (and (every (compose zero? cdr waitpid) 112 (append pids1 pids2))
113 (append pids1 pids2)) 113 (equal? (get-bytevector-all decompressed)
114 (equal? (get-bytevector-all decompressed) 114 (call-with-input-file file get-bytevector-all))))))
115 (call-with-input-file file get-bytevector-all))))))))
116 115
117(test-assert "filtered-port, non-file" 116(test-assert "filtered-port, non-file"
118 (let ((data (call-with-input-file (search-path %load-path "guix.scm") 117 (let ((data (call-with-input-file (search-path %load-path "guix.scm")