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 | (merge-pathnames "tmp/" *this-directory*)) |
---|
10 | |
---|
11 | (defun create-wild-test-hierarchy () |
---|
12 | (dolist (file *test-files*) |
---|
13 | (let ((file (merge-pathnames file *temp-directory-root*))) |
---|
14 | (ensure-directories-exist (directory-namestring file)) |
---|
15 | (touch file)))) |
---|
16 | |
---|
17 | (defun remove-wild-test-hierarchy () |
---|
18 | (delete-directory-and-files *temp-directory-root*)) |
---|
19 | |
---|
20 | (defmacro with-test-directories (&rest body) |
---|
21 | `(prog2 (create-wild-test-hierarchy) |
---|
22 | ,@body |
---|
23 | (remove-wild-test-hierarchy))) |
---|
24 | |
---|
25 | (defun set-equal (a b) |
---|
26 | (and |
---|
27 | (= (length a) (length b)) |
---|
28 | (subsetp a b :test #'equal) |
---|
29 | (subsetp b a :test #'equal))) |
---|
30 | |
---|
31 | (deftest wild-pathnames.1 |
---|
32 | (let ((results |
---|
33 | (with-test-directories |
---|
34 | (directory (merge-pathnames "**/*.ext" |
---|
35 | *temp-directory-root*)))) |
---|
36 | (expected |
---|
37 | (loop :for file :in *test-files* |
---|
38 | :collecting (merge-pathnames file |
---|
39 | *temp-directory-root*)))) |
---|
40 | (set-equal results expected)) |
---|
41 | t) |
---|
42 | |
---|
43 | ;;; XXX try to track this down by going to the git version? |
---|
44 | ;;; |
---|
45 | ;;; Passing, but some form of :VERSION :NEWEST was failing for |
---|
46 | ;;; ASDF-2.116 according to Faré in proviate email of 18.08.2010 |
---|
47 | (deftest wild-pathnames.2 |
---|
48 | (equal |
---|
49 | (first (with-test-directories |
---|
50 | (directory (make-pathname :directory (pathname-directory *temp-directory-root*) |
---|
51 | :name :wild :type "ext" |
---|
52 | :version :newest)))) |
---|
53 | (merge-pathnames *temp-directory-root* "foo.ext")) |
---|
54 | t) |
---|
55 | |
---|
56 | |
---|