summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-30 20:21:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-30 20:21:28 -0700
commitda08194bb7db19064ad82cc0d7341ff5ed1438e7 (patch)
treeb964d370dd9528ecc05cb5d0a1bd597c5f950209
parentcce3c4bef38888be015b0652d136e34c8ae7e59f (diff)
downloadtxr-da08194bb7db19064ad82cc0d7341ff5ed1438e7.tar.gz
txr-da08194bb7db19064ad82cc0d7341ff5ed1438e7.tar.bz2
txr-da08194bb7db19064ad82cc0d7341ff5ed1438e7.zip
gzio: some tests.
* tests/018/gzip.tl: New file.
-rw-r--r--tests/018/gzip.tl53
1 files changed, 53 insertions, 0 deletions
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"))