source: project/release/5/directory-utils/trunk/tests/directory-utils-test.scm @ 38963

Last change on this file since 38963 was 38963, checked in by Kon Lovett, 8 weeks ago

add -strict-types, remove redundant -local, update test runner, fix find-*-pathnames argument handling (match doc)

File size: 1.8 KB
Line 
1;;;; directory-utils-test.scm  -*- Scheme -*-
2;;;; Kon Lovett, Jul '18
3
4(import test)
5
6(import (only (chicken format) format))
7(include "test-gloss.incl")
8
9(test-begin "Directory Utils")
10
11(import directory-utils)
12
13;;;
14
15(test-assert (pathname? "abc/cbs.foo"))
16(test-assert (pathname? "abc/cbs"))
17(test-assert (pathname? ".abc"))
18(test-assert (not (pathname? "")))
19
20(test-assert (not (filename? "abc/cbs.foo")))
21(test-assert (filename? "cbs.foo"))
22
23(test-assert (not (dot-pathname? "abc/cbs.foo")))
24(test-assert (dot-pathname? "/abc/.hide/hidden"))
25(test-assert (not (dot-pathname? "/abc/cbs/./foo")))
26(test-assert (not (dot-pathname? "/abc/cbs/../foo")))
27(test-assert (dot-pathname? "/abc/cbs/../.foo"))
28(test-assert (dot-pathname? "/abc/cbs/../.foo/bar"))
29
30(test-assert (dot-filename? ".hide"))
31(test-assert (not (dot-filename? "/abc/.hide/hidden")))
32(test-assert (not (dot-filename? ".")))
33(test-assert (not (dot-filename? "..")))
34
35(test '("abc/cbs.foo") (remove-dotfiles '(".hide" "abc/cbs.foo")))
36
37(test-assert (which-command-pathname "mkdir"))
38(test-assert (not (which-command-pathname "93274030#$%)#)$()")))
39
40;run.scm test-gloss.incl.scm directory-utils-test.scm
41(cond-expand
42  (compiling  (define-constant TESTS-DIRECTORY-COUNT 4))
43  (else       (define-constant TESTS-DIRECTORY-COUNT 3)) )
44
45(test "directory-fold tests"
46  TESTS-DIRECTORY-COUNT
47  (directory-fold (lambda (fn ct) (add1 ct)) 0 "." #:dotfiles? #f))
48
49(test-assert (push-directory ".."))
50
51;tests .egg .scm
52(define-constant EGG-DIRECTORY-COUNT 3)
53
54(let ((fns (directory-fold cons '() "." #:dotfiles? #t)))
55  (glossf "Files: ~A" fns)
56  (test-assert "directory-fold tests/.." (<= EGG-DIRECTORY-COUNT (length fns))) )
57
58;NOTE at this point the same
59(test-assert (pop-directory))
60;(test-assert (pop-toplevel-directory))
61
62;;;
63
64(test-end "Directory Utils")
65
66(test-exit)
Note: See TracBrowser for help on using the repository browser.