(import (chicken base) (chicken blob) (chicken file posix) (chicken file) (chicken process) (test) (magic)) (test-begin "magic") (define test-file "test") (with-output-to-file test-file void) (test-error "bad argument" (identify '())) (test-error "nonexistent filename" (identify "whatever")) ;; TODO These should actually check the resulting string, if they give ;; identical values for the same inputs across various platforms and ;; libmagic versions (but I'm not sure whether they do or not). ;; ;; `string?` is half-assing it. (test-assert "blob" (string? (identify (make-blob 0)))) (test-assert "filename" (string? (identify test-file))) (test-assert "file descriptor" (let-values (((i o) (create-pipe))) (file-close o) (string? (identify i)))) (test-assert "input-port" (string? (call-with-input-file test-file identify))) (test-assert "no argument (current-input-port)" (string? (with-input-from-file test-file identify))) (test-assert "single flag" (string? (identify test-file 'mime))) (test-assert "multiple flags" (string? (identify test-file '(mime-type mime-encoding)))) (delete-file* test-file) (test-end "magic") (test-exit)