summary refs log tree commit diff
path: root/tests/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-03-24 21:09:15 +0100
committerLudovic Courtès <ludo@gnu.org>2014-03-24 21:09:15 +0100
commit80dea563a3dad98bda60385188509ca79a3651f8 (patch)
tree5b42a15306a812ed3a53e495a6f41840c8195b36 /tests/utils.scm
parent6ef91c8fc0798de87bc2fe3852f6dad5e6429cd4 (diff)
downloadguix-80dea563a3dad98bda60385188509ca79a3651f8.tar.gz
utils: Add 'filtered-output-port' and 'compressed-output-port'.
* guix/utils.scm (filtered-output-port, compressed-output-port): New
  procedures.
* tests/utils.scm ("compressed-output-port + decompressed-port"): New
  test.
Diffstat (limited to 'tests/utils.scm')
-rw-r--r--tests/utils.scm19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index 39cad701b8..adbfdf55ba 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -162,6 +162,25 @@
            (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)))))))
+
+(false-if-exception (delete-file temp-file))
 (test-equal "fcntl-flock wait"
   42                                              ; the child's exit status
   (let ((file (open-file temp-file "w0")))