;;;; directory-utils-test.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 (import test) (import (only (chicken format) format)) (include "test-gloss.incl") (test-begin "Directory Utils") (import directory-utils) ;;; (test-assert (pathname? "abc/cbs.foo")) (test-assert (pathname? "abc/cbs")) (test-assert (pathname? ".abc")) (test-assert (not (pathname? ""))) (test-assert (not (filename? "abc/cbs.foo"))) (test-assert (filename? "cbs.foo")) (test-assert (not (dot-pathname? "abc/cbs.foo"))) (test-assert (dot-pathname? "/abc/.hide/hidden")) (test-assert (not (dot-pathname? "/abc/cbs/./foo"))) (test-assert (not (dot-pathname? "/abc/cbs/../foo"))) (test-assert (dot-pathname? "/abc/cbs/../.foo")) (test-assert (dot-pathname? "/abc/cbs/../.foo/bar")) (test-assert (dot-filename? ".hide")) (test-assert (not (dot-filename? "/abc/.hide/hidden"))) (test-assert (not (dot-filename? "."))) (test-assert (not (dot-filename? ".."))) (test '("abc/cbs.foo") (remove-dotfiles '(".hide" "abc/cbs.foo"))) (test-assert (which-command-pathname "mkdir")) (test-assert (not (which-command-pathname "93274030#$%)#)$()"))) ;run.scm test-gloss.incl.scm directory-utils-test.scm (cond-expand (compiling (define-constant TESTS-DIRECTORY-COUNT 4)) (else (define-constant TESTS-DIRECTORY-COUNT 3)) ) (test "directory-fold tests" TESTS-DIRECTORY-COUNT (directory-fold (lambda (fn ct) (add1 ct)) 0 "." #:dotfiles? #f)) (test-assert (push-directory "..")) ;tests .egg .scm (define-constant EGG-DIRECTORY-COUNT 3) (let ((fns (directory-fold cons '() "." #:dotfiles? #t))) (glossf "Files: ~A" fns) (test-assert "directory-fold tests/.." (<= EGG-DIRECTORY-COUNT (length fns))) ) ;NOTE at this point the same (test-assert (pop-directory)) ;(test-assert (pop-toplevel-directory)) ;;; (test-end "Directory Utils") (test-exit)