diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-03-24 22:15:29 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-03-24 22:15:29 +0100 |
commit | 01ac19dca4318d577cf3bef53cfe6af590f0e5f8 (patch) | |
tree | 413b19db595ab5138a74a635419bd82aac5d3c24 /tests/utils.scm | |
parent | 80dea563a3dad98bda60385188509ca79a3651f8 (diff) |
utils: Add 'call-with-decompressed-port' and 'call-with-compressed-output-port'.
* guix/utils.scm (call-with-decompressed-port,
call-with-compressed-output-port): New procedures.
* tests/utils.scm ("compressed-output-port + decompressed-port"):
Rewrite to use them.
Diffstat (limited to 'tests/utils.scm')
-rw-r--r-- | tests/utils.scm | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index adbfdf55ba..1da847689c 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -162,23 +162,16 @@ (equal? (get-bytevector-all decompressed) data))))) (false-if-exception (delete-file temp-file)) -(test-equal "compressed-output-port + decompressed-port" - '((0) "Hello, compressed port!") - (let ((text "Hello, compressed port!") - (output (open-file temp-file "w0b"))) - (let-values (((compressed pids) - (compressed-output-port 'xz output))) - (display text compressed) - (close-port compressed) - (close-port output) - (and (every (compose zero? cdr waitpid) pids) - (let*-values (((input) - (open-file temp-file "r0b")) - ((decompressed pids) - (decompressed-port 'xz input))) - (let ((str (get-string-all decompressed))) - (list (map (compose cdr waitpid) pids) - str))))))) +(test-assert "compressed-output-port + decompressed-port" + (let* ((file (search-path %load-path "guix/derivations.scm")) + (data (call-with-input-file file get-bytevector-all))) + (call-with-compressed-output-port 'xz (open-file temp-file "w0b") + (lambda (compressed) + (put-bytevector compressed data))) + + (bytevector=? data + (call-with-decompressed-port 'xz (open-file temp-file "r0b") + get-bytevector-all)))) (false-if-exception (delete-file temp-file)) (test-equal "fcntl-flock wait" |