3 # This software is part of the SBCL system. See the README file for
6 # While most of SBCL is derived from the CMU CL system, the test
7 # files (like this one) were written from scratch after the fork
10 # This software is in the public domain and is provided with
11 # absolutely no warranty. See the COPYING and CREDITS files for
14 # Test DIRECTORY and TRUENAME.
15 testdir
=`/bin/pwd`"/filesys-test-$$"
17 echo this is a
test > $testdir/test-1.tmp
18 echo this is a
test > $testdir/test-2.tmp
19 echo this is a
test > $testdir/wild
\?test.tmp
21 ln -s test-1.tmp link-1
22 ln -s `pwd`/test-2.tmp link-2
23 ln -s i-do-not-exist link-3
26 ln -s `pwd`/link-6 link-5
28 "'(#p\"$testdir/link-3\"\
29 #p\"$testdir/link-4\"\
30 #p\"$testdir/link-5\"\
31 #p\"$testdir/link-6\"\
32 #p\"$testdir/test-1.tmp\"\
33 #p\"$testdir/test-2.tmp\"\
34 #p\"$testdir/wild\\\\?test.tmp\")"
37 (let* ((directory (directory "./*.*"))
38 (truenames (sort directory #'string< :key #'pathname-name)))
39 (format t "~&TRUENAMES=~S~%" truenames)
41 (assert (equal truenames $expected_truenames)))
42 (assert (equal (truename "test-1.tmp") #p"$testdir/test-1.tmp"))
43 (assert (equal (truename "link-1") #p"$testdir/test-1.tmp"))
44 (assert (equal (truename "link-2") #p"$testdir/test-2.tmp"))
45 (assert (equal (truename "link-3") #p"$testdir/link-3"))
46 (assert (equal (truename "link-4") #p"$testdir/link-4"))
47 (assert (equal (truename "link-5") #p"$testdir/link-5"))
48 (assert (equal (truename "link-6") #p"$testdir/link-6"))
49 (sb-ext:quit :unix-status 52)
52 echo DIRECTORY
/TRUENAME
test part
1 failed
, unexpected SBCL
return code
=$?
58 (let* ((directory (directory "$testdir/*.*"))
59 (truenames (sort directory #'string< :key #'pathname-name)))
60 (format t "~&TRUENAMES=~S~%" truenames)
62 (assert (equal truenames $expected_truenames)))
63 (assert (equal (truename "$testdir/test-1.tmp") #p"$testdir/test-1.tmp"))
64 (assert (equal (truename "$testdir/link-1") #p"$testdir/test-1.tmp"))
65 (assert (equal (truename "$testdir/link-2") #p"$testdir/test-2.tmp"))
66 (assert (equal (truename "$testdir/link-3") #p"$testdir/link-3"))
67 (assert (equal (truename "$testdir/link-4") #p"$testdir/link-4"))
68 (assert (equal (truename "$testdir/link-5") #p"$testdir/link-5"))
69 (assert (equal (truename "$testdir/link-6") #p"$testdir/link-6"))
70 (sb-ext:quit :unix-status 52)
73 echo DIRECTORY
/TRUENAME
test part
2 failed
, unexpected SBCL
return code
=$?
78 # Test DIRECTORY on a tree structure of directories.
83 mkdir animal
/vertebrate animal
/invertebrate
84 mkdir animal
/vertebrate
/mammal
85 mkdir animal
/vertebrate
/snake
86 mkdir animal
/vertebrate
/bird
87 mkdir animal
/vertebrate
/mammal
/bear
88 mkdir animal
/vertebrate
/mammal
/mythical
89 mkdir animal
/vertebrate
/mammal
/rodent
90 mkdir animal
/vertebrate
/mammal
/ruminant
91 touch animal
/vertebrate
/mammal
/platypus
92 touch animal
/vertebrate
/mammal
/walrus
93 touch animal
/vertebrate
/mammal
/bear
/grizzly
94 touch animal
/vertebrate
/mammal
/mythical
/mermaid
95 touch animal
/vertebrate
/mammal
/mythical
/unicorn
96 touch animal
/vertebrate
/mammal
/rodent
/beaver
97 touch animal
/vertebrate
/mammal
/rodent
/mouse
98 touch animal
/vertebrate
/mammal
/rodent
/rabbit
99 touch animal
/vertebrate
/mammal
/rodent
/rat
100 touch animal
/vertebrate
/mammal
/ruminant
/cow
101 touch animal
/vertebrate
/snake
/python
102 touch plant
/kingsfoil plant
/pipeweed
104 (in-package :cl-user)
105 (defun absolutify (pathname)
106 "Convert a possibly-relative pathname to absolute."
107 (merge-pathnames pathname
108 (make-pathname :directory
110 *default-pathname-defaults*))))
111 (defun sorted-truenamestrings (pathname-designators)
112 "Convert a collection of pathname designators into canonical form
113 using TRUENAME, NAMESTRING, and SORT."
114 (sort (mapcar #'namestring
116 pathname-designators))
118 (defun need-match-1 (directory-pathname result-sorted-truenamestrings)
120 (let ((directory-sorted-truenamestrings (sorted-truenamestrings
121 (directory directory-pathname))))
122 (unless (equal directory-sorted-truenamestrings
123 result-sorted-truenamestrings)
124 (format t "~&~@<DIRECTORY argument = ~_~2I~S~:>~%"
126 (format t "~&~@<DIRECTORY result = ~_~2I~S~:>~%"
127 directory-sorted-truenamestrings)
128 (format t "~&~@<expected result = ~_~2I~S.~:>~%"
129 result-sorted-truenamestrings)
130 (error "mismatch between DIRECTORY and expected result"))))
131 (defun need-match (directory-pathname result-pathnames)
132 "Require that (DIRECTORY DIRECTORY-PATHNAME) return RESULT-PATHNAMES
133 (modulo TRUENAME and NAMESTRING applied to each RESULT-PATHNAME for
134 convenience in e.g. converting Unix filename syntax idiosyncrasies to
135 Lisp filename syntax idiosyncrasies)."
136 (let ((sorted-result-truenamestrings (sorted-truenamestrings
138 ;; Relative and absolute pathnames should give the same result.
139 (need-match-1 directory-pathname
140 sorted-result-truenamestrings)
141 (need-match-1 (absolutify directory-pathname)
142 sorted-result-truenamestrings)))
143 (defun need-matches ()
144 "lotso calls to NEED-MATCH"
145 ;; FIXME: As discussed on sbcl-devel ca. 2001-01-01, DIRECTORY should
146 ;; report Unix directory files contained within its output as e.g.
147 ;; "/usr/bin" instead of the CMU-CL-style "/usr/bin/". In that case,
148 ;; s:/":": in most or all the NEED-MATCHes here.
149 (need-match "./*.*" '("animal/" "dirt" "plant/" "water"))
150 (need-match "*.*" '("animal/" "dirt" "plant/" "water"))
151 (need-match "animal" '("animal/"))
152 (need-match "./animal" '("animal/"))
153 (need-match "animal/*.*" '("animal/invertebrate/" "animal/vertebrate/"))
154 (need-match "animal/*/*.*"
155 '("animal/vertebrate/bird/"
156 "animal/vertebrate/mammal/"
157 "animal/vertebrate/snake/"))
158 (need-match "plant/*.*" '("plant/kingsfoil" "plant/pipeweed"))
159 (need-match "plant/**/*.*" '("plant/kingsfoil" "plant/pipeweed"))
160 (need-match "plant/**/**/*.*" '("plant/kingsfoil" "plant/pipeweed"))
161 (let ((vertebrates (mapcar (lambda (stem)
167 "mammal/bear/" "mammal/bear/grizzly"
168 "mammal/mythical/" "mammal/mythical/mermaid"
169 "mammal/mythical/unicorn"
171 "mammal/rodent/" "mammal/rodent/beaver"
172 "mammal/rodent/mouse" "mammal/rodent/rabbit"
174 "mammal/ruminant/" "mammal/ruminant/cow"
176 "snake/" "snake/python"))))
177 (need-match "animal/vertebrate/**/*.*" vertebrates)
178 (need-match "animal/vertebrate/mammal/../**/*.*" vertebrates)
179 (need-match "animal/vertebrate/mammal/../**/**/*.*" vertebrates)
180 (need-match "animal/vertebrate/mammal/mythical/../**/../**/*.*"
182 (need-match "animal/vertebrate/**/robot.*" nil)
183 (need-match "animal/vertebrate/mammal/../**/*.robot" nil)
184 (need-match "animal/vertebrate/mammal/../**/robot/*.*" nil)
185 (need-match "animal/vertebrate/mammal/robot/../**/../**/*.*" nil))
187 (sb-ext:quit :unix-status 52)
189 if [ $?
!= 52 ]; then
190 echo DIRECTORY
/TRUENAME
test part
1 failed
, unexpected SBCL
return code
=$?
196 # success convention for script