source: trunk/abcl/test/lisp/abcl/wild-pathnames.lisp

Last change on this file was 15332, checked in by Mark Evenson, 4 years ago

Revisions for the long neglected ABCL/TEST/LISP suite

Restore loading under SBCL and CCL.

FIXME: package-local-nicknames-tests only runs once in the same
process, causing a mysterious failure on the second time.

File size: 2.0 KB
Line 
1(in-package :abcl.test.lisp)
2
3;;; Various tests for PATHNAMES :WILD and :WILD-INFERIORS
4
5(defvar *test-files*
6  '("foo.ext" "a/b/c/foo.ext" "a/d/e/foo.ext" "b/foo.ext" "a/foo.ext"))
7
8(defvar *temp-directory-root* 
9  (ext:make-temp-directory))
10
11(defun create-wild-test-hierarchy ()
12  (ensure-directories-exist *temp-directory-root*)
13  (dolist (file *test-files*)
14    (let ((file (merge-pathnames file *temp-directory-root*)))
15      (ensure-directories-exist (directory-namestring file))
16      (unless (probe-file file)
17        (touch file)))))
18
19(defun remove-wild-test-hierarchy ()
20  (ignore-errors
21    (delete-directory-and-files *temp-directory-root*)))
22
23(defmacro with-test-directories (&rest body)
24  `(prog2 (create-wild-test-hierarchy)
25          ,@body
26     (remove-wild-test-hierarchy)))
27
28(defun set-equal (a b)
29  (and
30   (= (length a) (length b))
31   (subsetp a b :test #'equal)
32   (subsetp b a :test #'equal)))
33   
34(deftest wild-pathnames.1
35    (with-test-directories
36        (let ((results
37               (directory (merge-pathnames "**/*.ext"
38                                           *temp-directory-root*)))
39              (expected
40               (loop :for file :in *test-files*
41                  :collecting (merge-pathnames file
42                                               *temp-directory-root*))))
43      (values 
44       (eq (length results) (length expected))
45      ;; link --> file is not resolved by change in DIRECTORY to :RESOLVE-SYMLINKS nil
46       results
47       expected
48       (set-equal (mapcar #'truename results) 
49                  (mapcar #'truename expected)))))
50  t)
51
52(deftest wild-pathnames.2
53    (check-namestring
54     (namestring (first (with-test-directories
55                            (directory (make-pathname :directory (pathname-directory *temp-directory-root*)
56                                                      :name :wild :type "ext"
57                                                      :version :newest)))))
58     (namestring (merge-pathnames *temp-directory-root* "foo.ext")))
59  t)
60
61   
62
Note: See TracBrowser for help on using the repository browser.