From da08194bb7db19064ad82cc0d7341ff5ed1438e7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 30 May 2022 20:21:28 -0700 Subject: gzio: some tests. * tests/018/gzip.tl: New file. --- tests/018/gzip.tl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/018/gzip.tl diff --git a/tests/018/gzip.tl b/tests/018/gzip.tl new file mode 100644 index 00000000..3e7c9ef9 --- /dev/null +++ b/tests/018/gzip.tl @@ -0,0 +1,53 @@ +(load "../common") + +(if (not (fboundp 'usr:buf-compress)) + (exit)) + +(defvarl %have-gzip% (sh "gzip -h > /dev/null 2> /dev/null")) + +(defun shchk (cmd) + (unless (zerop (sh cmd)) + (throw `command @cmd failed`))) + +(defun gzip (. files) + (each ((file files)) + (file-put-string `@file.gz` (file-get-string file) "z"))) + +(defun cat (dest . files) + (remove-path dest) + (each ((file files)) + (file-append-string dest (file-get-string file)))) + +(push-after-load + (each ((file '#"test-file test-file.gz \ + test-file-a.tl test-file-a.tlo test-file-a.tlo.gz \ + test-file-b.tl test-file-b.tlo test-file-b.tlo.gz \ + test-file-combined.tlo.gz")) + (remove-path file))) + +(when %have-gzip% + (file-put-string "test-file" "Hello, World!") + (remove-path "test-file.gz") + (shchk "gzip test-file") + (test (file-get-string "test-file.gz" "z") "Hello, World!") + + (each ((mode (cons "z" (list-seq "z0".."z9")))) + (file-put-string "test-file.gz" "Goodbye, World!" mode) + (remove-path "test-file") + (shchk "gunzip test-file.gz") + (test (file-get-string "test-file") "Goodbye, World!")) + + (file-put "test-file-a.tl" '(compile-only (put-line "a"))) + (file-put "test-file-b.tl" '(compile-only (put-line "b"))) + + (compile-update-file "./test-file-a") + (compile-update-file "./test-file-b") + + (gzip "test-file-a.tlo" "test-file-b.tlo") + + (cat "test-file-combined.tlo.gz" "test-file-a.tlo.gz" "test-file-b.tlo.gz") + + (test + (with-out-string-stream (*stdout*) + (load "./test-file-combined.tlo.gz")) + "a\nb\n")) -- cgit v1.2.3