1 | ;;; pathname-tests.lisp |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2005 Peter Graves |
---|
4 | ;;; $Id: pathname-tests.lisp 11599 2009-01-29 16:00:07Z mevenson $ |
---|
5 | ;;; |
---|
6 | ;;; This program is free software; you can redistribute it and/or |
---|
7 | ;;; modify it under the terms of the GNU General Public License |
---|
8 | ;;; as published by the Free Software Foundation; either version 2 |
---|
9 | ;;; of the License, or (at your option) any later version. |
---|
10 | ;;; |
---|
11 | ;;; This program is distributed in the hope that it will be useful, |
---|
12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | ;;; GNU General Public License for more details. |
---|
15 | ;;; |
---|
16 | ;;; You should have received a copy of the GNU General Public License |
---|
17 | ;;; along with this program; if not, write to the Free Software |
---|
18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | (in-package #:abcl.test.lisp) |
---|
21 | |
---|
22 | (defun check-physical-pathname (pathname expected-directory expected-name expected-type) |
---|
23 | (let* ((directory (pathname-directory pathname)) |
---|
24 | (name (pathname-name pathname)) |
---|
25 | (type (pathname-type pathname)) |
---|
26 | (ok t)) |
---|
27 | (unless (and (pathnamep pathname) |
---|
28 | (not (typep pathname 'logical-pathname))) |
---|
29 | (setf ok nil)) |
---|
30 | (unless (and (equal directory expected-directory) |
---|
31 | (equal name expected-name) |
---|
32 | (equal type expected-type)) |
---|
33 | (setf ok nil)) |
---|
34 | ok)) |
---|
35 | |
---|
36 | (defun check-windows-pathname (pathname expected-host expected-device |
---|
37 | expected-directory expected-name |
---|
38 | expected-type) |
---|
39 | (let* ((host (pathname-host pathname)) |
---|
40 | (device (pathname-device pathname)) |
---|
41 | (directory (pathname-directory pathname)) |
---|
42 | (name (pathname-name pathname)) |
---|
43 | (type (pathname-type pathname)) |
---|
44 | (ok t)) |
---|
45 | (unless (and (pathnamep pathname) |
---|
46 | (not (typep pathname 'logical-pathname))) |
---|
47 | (setf ok nil)) |
---|
48 | (unless (and (equal host expected-host) |
---|
49 | (equal device expected-device) |
---|
50 | (equal directory expected-directory) |
---|
51 | (equal name expected-name) |
---|
52 | (equal type expected-type)) |
---|
53 | (setf ok nil)) |
---|
54 | ok)) |
---|
55 | |
---|
56 | (defun check-logical-pathname (pathname expected-host expected-directory |
---|
57 | expected-name expected-type |
---|
58 | expected-version) |
---|
59 | (let* ((host (pathname-host pathname)) |
---|
60 | (directory (pathname-directory pathname)) |
---|
61 | (name (pathname-name pathname)) |
---|
62 | (type (pathname-type pathname)) |
---|
63 | (version (pathname-version pathname)) |
---|
64 | ;; Allegro's logical pathnames don't canonicalize their string |
---|
65 | ;; components to upper case. |
---|
66 | (test #-allegro 'equal |
---|
67 | #+allegro 'equalp) |
---|
68 | (ok t)) |
---|
69 | (unless (typep pathname 'logical-pathname) |
---|
70 | (setf ok nil)) |
---|
71 | ;; "The device component of a logical pathname is always :UNSPECIFIC..." 19.3.2.1 |
---|
72 | #-allegro ;; Except on Allegro, where it's NIL. |
---|
73 | (unless (eq (pathname-device pathname) :unspecific) |
---|
74 | (setf ok nil)) |
---|
75 | (unless (and (funcall test (if (stringp host) host |
---|
76 | (host-namestring pathname)) |
---|
77 | expected-host) |
---|
78 | (funcall test directory expected-directory) |
---|
79 | (funcall test name expected-name) |
---|
80 | (funcall test type expected-type) |
---|
81 | (eql version expected-version)) |
---|
82 | (setf ok nil)) |
---|
83 | ok)) |
---|
84 | |
---|
85 | (defun check-merge-pathnames (pathname default-pathname expected-result) |
---|
86 | (let* ((result (merge-pathnames pathname default-pathname)) |
---|
87 | (test #-allegro 'equal |
---|
88 | #+allegro (if (typep result 'logical-pathname) |
---|
89 | 'equalp |
---|
90 | 'equal))) |
---|
91 | (and (funcall test (pathname-host result) (pathname-host expected-result)) |
---|
92 | (funcall test (pathname-directory result) (pathname-directory expected-result)) |
---|
93 | (funcall test (pathname-name result) (pathname-name expected-result)) |
---|
94 | (funcall test (pathname-type result) (pathname-type expected-result))))) |
---|
95 | |
---|
96 | (defun check-translate-pathname (args expected) |
---|
97 | (declare (optimize safety)) |
---|
98 | (declare (type list args)) |
---|
99 | (declare (type string expected)) |
---|
100 | (let ((result (namestring (apply 'translate-pathname args)))) |
---|
101 | (equal result |
---|
102 | #-windows expected |
---|
103 | #+windows (substitute #\\ #\/ expected)))) |
---|
104 | |
---|
105 | (defmacro check-readable (pathname) |
---|
106 | `(equal ,pathname (read-from-string (write-to-string ,pathname :readably t)))) |
---|
107 | |
---|
108 | (defun check-readable-or-signals-error (pathname) |
---|
109 | (handler-case |
---|
110 | (equal pathname (read-from-string (write-to-string pathname :readably t))) |
---|
111 | (print-not-readable () t))) |
---|
112 | |
---|
113 | (defmacro check-namestring (pathname namestring) |
---|
114 | `(string= (namestring ,pathname) |
---|
115 | #+windows (substitute #\\ #\/ ,namestring) |
---|
116 | #-windows ,namestring)) |
---|
117 | |
---|
118 | ;; Define a logical host. |
---|
119 | (setf (logical-pathname-translations "effluvia") |
---|
120 | '(("**;*.*.*" "/usr/local/**/*.*"))) |
---|
121 | |
---|
122 | (deftest equal.1 |
---|
123 | (equal (make-pathname :name "foo" :type "bar") |
---|
124 | (make-pathname :name "foo" :type "bar")) |
---|
125 | t) |
---|
126 | |
---|
127 | (deftest equal.2 |
---|
128 | (equal (make-pathname :name "foo" :type "bar" :version nil) |
---|
129 | (make-pathname :name "foo" :type "bar" :version :newest)) |
---|
130 | #+(or clisp lispworks) nil |
---|
131 | #-(or clisp lispworks) t) |
---|
132 | |
---|
133 | (deftest sxhash.1 |
---|
134 | (let* ((p (make-pathname :name "foo" :type "bar" :version nil)) |
---|
135 | (s (sxhash p))) |
---|
136 | (values (typep s 'fixnum) |
---|
137 | (>= s 0))) |
---|
138 | t t) |
---|
139 | |
---|
140 | ;; "(equal x y) implies (= (sxhash x) (sxhash y))" |
---|
141 | (deftest sxhash.2 |
---|
142 | (let ((p1 (make-pathname :name "foo" :type "bar" :version nil)) |
---|
143 | (p2 (make-pathname :name "foo" :type "bar" :version :newest))) |
---|
144 | (if (equal p1 p2) |
---|
145 | (= (sxhash p1) (sxhash p2)) |
---|
146 | t)) |
---|
147 | t) |
---|
148 | |
---|
149 | ;; It's suboptimal if all pathnames return the same SXHASH, but that happens |
---|
150 | ;; with SBCL. |
---|
151 | (deftest sxhash.3 |
---|
152 | (= (sxhash #p"/usr/local/bin/sbcl") (sxhash #p"") (sxhash #p"foo.bar")) |
---|
153 | #+sbcl t |
---|
154 | #-sbcl nil) |
---|
155 | |
---|
156 | ;; "Parsing a null string always succeeds, producing a pathname with all |
---|
157 | ;; components (except the host) equal to nil." |
---|
158 | (deftest physical.1 |
---|
159 | (check-physical-pathname #p"" nil nil nil) |
---|
160 | t) |
---|
161 | |
---|
162 | (deftest physical.2 |
---|
163 | (check-physical-pathname #p"/" '(:absolute) nil nil) |
---|
164 | t) |
---|
165 | |
---|
166 | (deftest physical.3 |
---|
167 | (check-physical-pathname #p"/foo" '(:absolute) "foo" nil) |
---|
168 | t) |
---|
169 | |
---|
170 | (deftest physical.4 |
---|
171 | #-lispworks |
---|
172 | (check-physical-pathname #p"/foo." '(:absolute) "foo" "") |
---|
173 | #+lispworks |
---|
174 | (check-physical-pathname #p"/foo." '(:absolute) "foo." nil) |
---|
175 | t) |
---|
176 | |
---|
177 | (deftest physical.5 |
---|
178 | (check-physical-pathname #p"/foo.bar" '(:absolute) "foo" "bar") |
---|
179 | t) |
---|
180 | |
---|
181 | (deftest physical.6 |
---|
182 | #-lispworks |
---|
183 | (check-physical-pathname #p"/foo.bar." '(:absolute) "foo.bar" "") |
---|
184 | #+lispworks |
---|
185 | (check-physical-pathname #p"/foo.bar." '(:absolute) "foo.bar." nil) |
---|
186 | t) |
---|
187 | |
---|
188 | (deftest physical.7 |
---|
189 | (check-physical-pathname #p"/foo.bar.baz" '(:absolute) "foo.bar" "baz") |
---|
190 | t) |
---|
191 | |
---|
192 | (deftest physical.8 |
---|
193 | (check-physical-pathname #p"/foo/bar" '(:absolute "foo") "bar" nil) |
---|
194 | t) |
---|
195 | |
---|
196 | (deftest physical.9 |
---|
197 | (check-physical-pathname #p"/foo..bar" '(:absolute) "foo." "bar") |
---|
198 | t) |
---|
199 | |
---|
200 | (deftest physical.10 |
---|
201 | (check-physical-pathname #p"foo.bar" nil "foo" "bar") |
---|
202 | t) |
---|
203 | |
---|
204 | (deftest physical.11 |
---|
205 | (check-physical-pathname #p"foo.bar.baz" nil "foo.bar" "baz") |
---|
206 | t) |
---|
207 | |
---|
208 | (deftest physical.12 |
---|
209 | (check-physical-pathname #p"foo/" '(:relative "foo") nil nil) |
---|
210 | t) |
---|
211 | |
---|
212 | (deftest physical.13 |
---|
213 | (check-physical-pathname #p"foo/bar" '(:relative "foo") "bar" nil) |
---|
214 | t) |
---|
215 | |
---|
216 | (deftest physical.14 |
---|
217 | (check-physical-pathname #p"foo/bar/baz" '(:relative "foo" "bar") "baz" nil) |
---|
218 | t) |
---|
219 | |
---|
220 | (deftest physical.15 |
---|
221 | (check-physical-pathname #p"foo/bar/" '(:relative "foo" "bar") nil nil) |
---|
222 | t) |
---|
223 | |
---|
224 | #+allegro |
---|
225 | (deftest physical.16 |
---|
226 | ;; This reduction is wrong. |
---|
227 | (check-physical-pathname #p"foo/bar/.." '(:relative "foo") nil nil) |
---|
228 | t) |
---|
229 | |
---|
230 | #+allegro |
---|
231 | (deftest physical.17 |
---|
232 | (check-physical-pathname #p"/foo/../" '(:absolute) nil nil) |
---|
233 | t) |
---|
234 | |
---|
235 | (deftest physical.18 |
---|
236 | #-lispworks |
---|
237 | (check-physical-pathname #p".lisprc" nil ".lisprc" nil) |
---|
238 | #+lispworks |
---|
239 | (check-physical-pathname #p".lisprc" nil "" "lisprc") |
---|
240 | t) |
---|
241 | |
---|
242 | (deftest physical.19 |
---|
243 | (check-physical-pathname #p"x.lisprc" nil "x" "lisprc") |
---|
244 | t) |
---|
245 | |
---|
246 | (deftest physical.20 |
---|
247 | #-allegro |
---|
248 | (check-physical-pathname (make-pathname :name ".") nil "." nil) |
---|
249 | #+allegro |
---|
250 | (check-physical-pathname (make-pathname :name ".") '(:relative) nil nil) |
---|
251 | t) |
---|
252 | |
---|
253 | (deftest physical.21 |
---|
254 | #-cmu |
---|
255 | (check-readable (make-pathname :name ".")) |
---|
256 | #+cmu |
---|
257 | (check-readable-or-signals-error (make-pathname :name ".")) |
---|
258 | t) |
---|
259 | #+(or cmu lispworks (and allegro windows)) |
---|
260 | (pushnew 'physical.21 *expected-failures*) |
---|
261 | |
---|
262 | ;; #p"." |
---|
263 | (deftest physical.22 |
---|
264 | #+(or allegro abcl cmu) |
---|
265 | (check-physical-pathname #p"." '(:relative) nil nil) |
---|
266 | #-(or allegro abcl cmu) |
---|
267 | ;; No trailing separator character means it's a file. |
---|
268 | (check-physical-pathname #p"." nil "." nil) |
---|
269 | t) |
---|
270 | #+lispworks |
---|
271 | (pushnew 'physical.22 *expected-failures*) |
---|
272 | |
---|
273 | (deftest namestring.1 |
---|
274 | (check-namestring #p"." |
---|
275 | #+(or abcl allegro cmu) "./" |
---|
276 | #-(or abcl allegro cmu) ".") |
---|
277 | t) |
---|
278 | #+lispworks |
---|
279 | (pushnew 'namestring.1 *expected-failures*) |
---|
280 | |
---|
281 | (deftest physical.23 |
---|
282 | (equal #p"." #p"") |
---|
283 | nil) |
---|
284 | #+lispworks |
---|
285 | (pushnew 'physical.23 *expected-failures*) |
---|
286 | |
---|
287 | ;; #p"./" |
---|
288 | ;; Trailing separator character means it's a directory. |
---|
289 | (deftest physical.24 |
---|
290 | (let ((pathname #-windows #p"./" |
---|
291 | #+windows #p".\\")) |
---|
292 | #-(or sbcl) |
---|
293 | (check-physical-pathname pathname '(:relative) nil nil) |
---|
294 | #+(or sbcl) |
---|
295 | ;; Is this more exact? |
---|
296 | (check-physical-pathname pathname '(:relative ".") nil nil)) |
---|
297 | t) |
---|
298 | #+(or lispworks (and allegro windows)) |
---|
299 | (pushnew 'physical.24 *expected-failures*) |
---|
300 | |
---|
301 | (deftest namestring.2 |
---|
302 | (check-namestring #-windows #p"./" |
---|
303 | #+windows #p".\\" |
---|
304 | "./") |
---|
305 | t) |
---|
306 | #+lispworks |
---|
307 | (pushnew 'namestring.2 *expected-failures*) |
---|
308 | |
---|
309 | (deftest directory-namestring.1 |
---|
310 | (equal (directory-namestring #-windows #p"./" |
---|
311 | #+windows #p".\\") |
---|
312 | #-windows "./" |
---|
313 | #+windows ".\\") |
---|
314 | t) |
---|
315 | #+lispworks |
---|
316 | (pushnew 'directory-namestring.1 *expected-failures*) |
---|
317 | |
---|
318 | (deftest physical.25 |
---|
319 | (equal #-windows #p"./" |
---|
320 | #+windows #p".\\" |
---|
321 | #p"") |
---|
322 | nil) |
---|
323 | #+(or lispworks (and allegro windows)) |
---|
324 | (pushnew 'physical.25 *expected-failures*) |
---|
325 | |
---|
326 | (deftest physical.26 |
---|
327 | #-allegro |
---|
328 | (check-physical-pathname (make-pathname :name "..") nil ".." nil) |
---|
329 | #+allegro |
---|
330 | (check-physical-pathname (make-pathname :name "..") '(:relative :back) nil nil) |
---|
331 | t) |
---|
332 | |
---|
333 | #-(or sbcl) |
---|
334 | (deftest physical.27 |
---|
335 | #-cmu |
---|
336 | (check-readable (make-pathname :name "..")) |
---|
337 | #+cmu |
---|
338 | (check-readable-or-signals-error (make-pathname :name "..")) |
---|
339 | t) |
---|
340 | #+(or clisp cmu lispworks) |
---|
341 | (pushnew 'physical.27 *expected-failures*) |
---|
342 | |
---|
343 | ;; #p".." |
---|
344 | (deftest physical.28 |
---|
345 | #+(or allegro (and lispworks windows)) |
---|
346 | (check-physical-pathname #p".." '(:relative :back) nil nil) |
---|
347 | #+(or abcl cmu (and lispworks unix)) |
---|
348 | (check-physical-pathname #p".." '(:relative :up) nil nil) |
---|
349 | ;; Other implementations think it's a file. |
---|
350 | #+(or) |
---|
351 | ;; If it's a file, to a human its name would be "..". No implementation gets |
---|
352 | ;; this right. |
---|
353 | (check-physical-pathname #p".." nil ".." nil) |
---|
354 | #+(or sbcl clisp) |
---|
355 | ;; These implementations parse ".." as the name "." followed by another dot and |
---|
356 | ;; the type string "", which no human would do. |
---|
357 | (check-physical-pathname #p".." nil "." "") |
---|
358 | t) |
---|
359 | #+cmu |
---|
360 | (pushnew 'physical.28 *expected-failures*) |
---|
361 | |
---|
362 | (deftest namestring.3 |
---|
363 | (check-namestring #p".." |
---|
364 | #+(or abcl allegro cmu lispworks) "../" |
---|
365 | #-(or abcl allegro cmu lispworks) "..") |
---|
366 | t) |
---|
367 | |
---|
368 | ;; #p"../" |
---|
369 | (deftest physical.29 |
---|
370 | (let ((pathname #-windows #p"../" |
---|
371 | #+windows #p"..\\")) |
---|
372 | #+(or allegro (and lispworks windows)) |
---|
373 | (check-physical-pathname pathname '(:relative :back) nil nil) |
---|
374 | #+(or abcl sbcl cmu clisp (and lispworks unix)) |
---|
375 | (check-physical-pathname pathname '(:relative :up) nil nil)) |
---|
376 | t) |
---|
377 | |
---|
378 | (deftest namestring.4 |
---|
379 | (check-namestring #-windows #p"../" |
---|
380 | #+windows #p"..\\" |
---|
381 | "../") |
---|
382 | t) |
---|
383 | |
---|
384 | (deftest directory-namestring.2 |
---|
385 | (equal (directory-namestring #-windows #p"../" |
---|
386 | #+windows #p"..\\") |
---|
387 | #-windows "../" |
---|
388 | #+windows "..\\") |
---|
389 | t) |
---|
390 | |
---|
391 | #-sbcl |
---|
392 | (deftest physical.30 |
---|
393 | #-(or allegro cmu) |
---|
394 | (string= (namestring (make-pathname :name "..")) "..") |
---|
395 | #+allegro |
---|
396 | (string= (namestring (make-pathname :name "..")) |
---|
397 | #-windows "../" |
---|
398 | #+windows "..\\") |
---|
399 | #+cmu |
---|
400 | (signals-error (make-pathname :name "..") 'warning) |
---|
401 | t) |
---|
402 | |
---|
403 | (deftest physical.31 |
---|
404 | (string= (namestring (make-pathname :directory '(:relative :up))) |
---|
405 | #+windows "..\\" |
---|
406 | #-windows "../") |
---|
407 | t) |
---|
408 | |
---|
409 | #+windows |
---|
410 | (deftest windows.1 |
---|
411 | (equal #p"/foo/bar/baz" #p"\\foo\\bar\\baz") |
---|
412 | t) |
---|
413 | |
---|
414 | #+windows |
---|
415 | (deftest windows.2 |
---|
416 | (let ((pathname #p"foo.bar")) |
---|
417 | (check-windows-pathname pathname nil nil nil "foo" "bar")) |
---|
418 | t) |
---|
419 | |
---|
420 | #+windows |
---|
421 | (deftest windows.3 |
---|
422 | (let ((pathname #p"\\foo.bar")) |
---|
423 | (check-windows-pathname pathname nil nil '(:absolute) "foo" "bar")) |
---|
424 | t) |
---|
425 | |
---|
426 | #+windows |
---|
427 | (deftest windows.4 |
---|
428 | (let ((pathname #p"c:\\foo.bar")) |
---|
429 | #+(or abcl allegro) |
---|
430 | (check-windows-pathname pathname nil "c" '(:absolute) "foo" "bar") |
---|
431 | #+clisp |
---|
432 | (check-windows-pathname pathname nil "C" '(:absolute) "foo" "bar") |
---|
433 | #+lispworks |
---|
434 | (check-windows-pathname pathname "c" nil '(:absolute) "foo" "bar")) |
---|
435 | t) |
---|
436 | |
---|
437 | #+windows |
---|
438 | (deftest windows.5 |
---|
439 | (equal #p"c:\\foo.bar" #p"C:\\FOO.BAR") |
---|
440 | t) |
---|
441 | |
---|
442 | (deftest wild.1 |
---|
443 | (check-physical-pathname #p"foo.*" nil "foo" :wild) |
---|
444 | t) |
---|
445 | |
---|
446 | (deftest wild.2 |
---|
447 | (check-physical-pathname #p"*.*" nil :wild :wild) |
---|
448 | t) |
---|
449 | |
---|
450 | (deftest wild.3 |
---|
451 | #-(or cmu sbcl) |
---|
452 | (check-physical-pathname #p"abc*" nil "abc*" nil) |
---|
453 | #+(or cmu sbcl) |
---|
454 | (wild-pathname-p #p"abc*") |
---|
455 | t) |
---|
456 | |
---|
457 | (deftest wild.4 |
---|
458 | #-(or cmu sbcl) |
---|
459 | (check-physical-pathname #p"abc?" nil "abc?" nil) |
---|
460 | #+(or cmu sbcl) |
---|
461 | (wild-pathname-p #p"abc?") |
---|
462 | t) |
---|
463 | |
---|
464 | (deftest wild.5 |
---|
465 | #-(or cmu sbcl) |
---|
466 | (check-physical-pathname #p"abc[d-h]" nil "abc[d-h]" nil) |
---|
467 | #+(or cmu sbcl) |
---|
468 | (wild-pathname-p #p"abc[d-h]") |
---|
469 | t) |
---|
470 | |
---|
471 | ;; Lots of dots. |
---|
472 | #+(or allegro abcl cmu) |
---|
473 | (deftest lots-of-dots.1 |
---|
474 | (check-physical-pathname #p"..." nil "..." nil) |
---|
475 | t) |
---|
476 | #+cmu |
---|
477 | (pushnew 'lots-of-dots.1 *expected-failures*) |
---|
478 | |
---|
479 | #+(or allegro abcl cmu) |
---|
480 | (deftest lots-of-dots.2 |
---|
481 | (check-physical-pathname #p"......" nil "......" nil) |
---|
482 | t) |
---|
483 | #+cmu |
---|
484 | (pushnew 'lots-of-dots.2 *expected-failures*) |
---|
485 | |
---|
486 | ;; Silly names. |
---|
487 | #-(or allegro sbcl) |
---|
488 | (deftest silly.1 |
---|
489 | #+(or abcl clisp) |
---|
490 | (signals-error (make-pathname :name "abc/def") 'error) |
---|
491 | #-(or abcl clisp) |
---|
492 | (check-readable (make-pathname :name "abc/def")) |
---|
493 | t) |
---|
494 | #+(or cmu lispworks) |
---|
495 | (pushnew 'silly.1 *expected-failures*) |
---|
496 | |
---|
497 | (deftest silly.2 |
---|
498 | (signals-error (make-pathname :name "abc/def") |
---|
499 | #-cmu 'error |
---|
500 | #+cmu 'warning) |
---|
501 | t) |
---|
502 | |
---|
503 | (deftest silly.3 |
---|
504 | (check-readable-or-signals-error (make-pathname :name ".foo")) |
---|
505 | t) |
---|
506 | |
---|
507 | (deftest silly.4 |
---|
508 | (check-readable-or-signals-error (make-pathname :type ".foo")) |
---|
509 | t) |
---|
510 | |
---|
511 | (deftest silly.5 |
---|
512 | (check-readable-or-signals-error (make-pathname :name "abc.def")) |
---|
513 | t) |
---|
514 | |
---|
515 | (deftest silly.6 |
---|
516 | (check-readable-or-signals-error (make-pathname :type "abc.def")) |
---|
517 | t) |
---|
518 | |
---|
519 | ;; LOGICAL-PATHNAME-TRANSLATIONS |
---|
520 | #-allegro |
---|
521 | (deftest logical-pathname-translations.1 |
---|
522 | #+(or sbcl cmu lispworks) |
---|
523 | (equal (logical-pathname-translations "effluvia") |
---|
524 | '(("**;*.*.*" "/usr/local/**/*.*"))) |
---|
525 | #+clisp |
---|
526 | (equal (logical-pathname-translations "effluvia") |
---|
527 | '((#p"EFFLUVIA:**;*.*.*" "/usr/local/**/*.*"))) |
---|
528 | #+abcl |
---|
529 | (equal (logical-pathname-translations "effluvia") |
---|
530 | '((#p"EFFLUVIA:**;*.*.*" #p"/usr/local/**/*.*"))) |
---|
531 | t) |
---|
532 | |
---|
533 | ;; "The null string, "", is not a valid value for any component of a logical |
---|
534 | ;; pathname." 19.3.2.2 |
---|
535 | (deftest logical-pathname.1 |
---|
536 | #-clisp |
---|
537 | (signals-error (logical-pathname ":") 'error) |
---|
538 | #+clisp |
---|
539 | (check-logical-pathname (logical-pathname ":") "" '(:absolute) nil nil nil) |
---|
540 | t) |
---|
541 | |
---|
542 | ;; Parse error. |
---|
543 | (deftest logical-pathname.2 |
---|
544 | (signals-error (logical-pathname "effluvia::foo.bar") |
---|
545 | #-(or allegro clisp) 'parse-error |
---|
546 | #+(or allegro clisp) 'type-error) |
---|
547 | t) |
---|
548 | |
---|
549 | ;; If the prefix isn't a defined logical host, it's not a logical pathname. |
---|
550 | #-(or cmu (and clisp windows)) |
---|
551 | ;; CMUCL parses this as (:ABSOLUTE #<SEARCH-LIST foo>) "bar.baz" "42". |
---|
552 | ;; CLISP signals a parse error reading #p"foo:bar.baz.42". |
---|
553 | (deftest logical.1 |
---|
554 | (let ((pathname #p"foo:bar.baz.42")) |
---|
555 | #+allegro |
---|
556 | ;; Except in Allegro. |
---|
557 | (check-logical-pathname pathname "foo" nil "bar" "baz" nil) |
---|
558 | #-allegro |
---|
559 | (check-physical-pathname pathname nil "foo:bar.baz" "42")) |
---|
560 | t) |
---|
561 | #+lispworks |
---|
562 | (pushnew 'logical.1 *expected-failures*) |
---|
563 | |
---|
564 | #+sbcl |
---|
565 | (deftest logical.2 |
---|
566 | ;; Even though "effluvia" is defined as a logical host, "bop" is not a valid |
---|
567 | ;; logical pathname version, so this can't be a logical pathname. |
---|
568 | (check-physical-pathname #p"effluvia:bar.baz.bop" nil "effluvia:bar.baz" "bop") |
---|
569 | t) |
---|
570 | |
---|
571 | (deftest logical.3 |
---|
572 | #-allegro |
---|
573 | (check-logical-pathname (make-pathname :defaults "effluvia:foo.lisp") |
---|
574 | "EFFLUVIA" '(:absolute) "FOO" "LISP" nil) |
---|
575 | #+allegro |
---|
576 | (check-logical-pathname (make-pathname :defaults "effluvia:foo.lisp") |
---|
577 | "effluvia" nil "foo" "lisp" nil) |
---|
578 | t) |
---|
579 | |
---|
580 | #-allegro |
---|
581 | (deftest logical.4 |
---|
582 | (check-logical-pathname #p"effluvia:bar.baz.42" "EFFLUVIA" '(:absolute) "BAR" "BAZ" 42) |
---|
583 | t) |
---|
584 | |
---|
585 | #-allegro |
---|
586 | (deftest logical.5 |
---|
587 | (string= (write-to-string #p"effluvia:bar.baz.42" :escape t) |
---|
588 | "#P\"EFFLUVIA:BAR.BAZ.42\"") |
---|
589 | t) |
---|
590 | |
---|
591 | #+allegro |
---|
592 | ;; Allegro returns NIL for the device and directory and drops the version |
---|
593 | ;; entirely (even from the namestring). |
---|
594 | (deftest logical.6 |
---|
595 | (check-logical-pathname #p"effluvia:bar.baz.42" "effluvia" nil "bar" "baz" nil) |
---|
596 | t) |
---|
597 | |
---|
598 | #+allegro |
---|
599 | (deftest logical.7 |
---|
600 | (string= (write-to-string #p"effluvia:bar.baz" :escape t) |
---|
601 | #+allegro-v6.2 "#p\"effluvia:bar.baz\"" |
---|
602 | #+allegro-v7.0 "#P\"effluvia:bar.baz\"") |
---|
603 | t) |
---|
604 | |
---|
605 | (deftest logical.8 |
---|
606 | (typep (parse-namestring "**;*.*.*" "effluvia") 'logical-pathname) |
---|
607 | t) |
---|
608 | |
---|
609 | (deftest logical.9 |
---|
610 | (check-namestring (parse-namestring "**;*.*.*" "effluvia") |
---|
611 | #-(or allegro lispworks) |
---|
612 | "EFFLUVIA:**;*.*.*" |
---|
613 | #+allegro |
---|
614 | ;; Allegro preserves case and drops the version component. |
---|
615 | "effluvia:**;*.*" |
---|
616 | #+lispworks |
---|
617 | "effluvia:**;*.*.*") |
---|
618 | t) |
---|
619 | |
---|
620 | #-allegro |
---|
621 | ;; The version can be a bignum. |
---|
622 | (deftest logical.10 |
---|
623 | (check-logical-pathname #p"effluvia:bar.baz.2147483648" "EFFLUVIA" '(:absolute) "BAR" "BAZ" 2147483648) |
---|
624 | t) |
---|
625 | |
---|
626 | #-allegro |
---|
627 | (deftest logical.11 |
---|
628 | (check-namestring #p"effluvia:bar.baz.2147483648" "EFFLUVIA:BAR.BAZ.2147483648") |
---|
629 | t) |
---|
630 | #+sbcl |
---|
631 | ;; SBCL has a bug when the version is a bignum. |
---|
632 | (pushnew 'logical.11 *expected-failures*) |
---|
633 | |
---|
634 | (deftest logical.12 |
---|
635 | (check-namestring #p"effluvia:foo.bar.newest" |
---|
636 | #-allegro "EFFLUVIA:FOO.BAR.NEWEST" |
---|
637 | #+allegro "effluvia:foo.bar") |
---|
638 | t) |
---|
639 | |
---|
640 | (deftest logical.13 |
---|
641 | #-allegro |
---|
642 | (check-logical-pathname #p"effluvia:foo.*" "EFFLUVIA" '(:absolute) "FOO" :wild nil) |
---|
643 | #+allegro |
---|
644 | (check-logical-pathname #p"effluvia:foo.*" "effluvia" nil "foo" :wild nil) |
---|
645 | t) |
---|
646 | |
---|
647 | (deftest logical.14 |
---|
648 | #-allegro |
---|
649 | (check-logical-pathname #p"effluvia:*.lisp" "EFFLUVIA" '(:absolute) :wild "LISP" nil) |
---|
650 | #+allegro |
---|
651 | (check-logical-pathname #p"effluvia:*.lisp" "effluvia" nil :wild "lisp" nil) |
---|
652 | t) |
---|
653 | |
---|
654 | (deftest logical.15 |
---|
655 | #-allegro |
---|
656 | (check-logical-pathname #p"effluvia:bar.baz.newest" "EFFLUVIA" '(:absolute) "BAR" "BAZ" :newest) |
---|
657 | #+allegro |
---|
658 | (check-logical-pathname #p"effluvia:bar.baz.newest" "effluvia" nil "bar" "baz" nil) |
---|
659 | t) |
---|
660 | |
---|
661 | (deftest logical.16 |
---|
662 | #-allegro |
---|
663 | (check-logical-pathname #p"EFFLUVIA:BAR.BAZ.NEWEST" "EFFLUVIA" '(:absolute) "BAR" "BAZ" :newest) |
---|
664 | #+allegro |
---|
665 | (check-logical-pathname #p"EFFLUVIA:BAR.BAZ.NEWEST" "EFFLUVIA" nil "BAR" "BAZ" nil) |
---|
666 | t) |
---|
667 | |
---|
668 | ;; The directory component. |
---|
669 | (deftest logical.17 |
---|
670 | (check-logical-pathname #p"effluvia:foo;bar.baz" "EFFLUVIA" '(:absolute "FOO") "BAR" "BAZ" nil) |
---|
671 | t) |
---|
672 | |
---|
673 | (deftest logical.18 |
---|
674 | (check-namestring #p"effluvia:foo;bar.baz" |
---|
675 | #-allegro "EFFLUVIA:FOO;BAR.BAZ" |
---|
676 | #+allegro "effluvia:foo;bar.baz") |
---|
677 | t) |
---|
678 | |
---|
679 | (deftest logical.19 |
---|
680 | #-allegro |
---|
681 | (check-logical-pathname #p"effluvia:;bar.baz" "EFFLUVIA" '(:relative) "BAR" "BAZ" nil) |
---|
682 | #+allegro |
---|
683 | ;; Allegro drops the directory component and removes the semicolon from the |
---|
684 | ;; namestring. |
---|
685 | (check-logical-pathname #p"effluvia:;bar.baz" "EFFLUVIA" nil "BAR" "BAZ" nil) |
---|
686 | t) |
---|
687 | |
---|
688 | (deftest logical.20 |
---|
689 | (check-namestring #p"effluvia:;bar.baz" |
---|
690 | #+allegro "effluvia:bar.baz" |
---|
691 | #-allegro "EFFLUVIA:;BAR.BAZ") |
---|
692 | t) |
---|
693 | |
---|
694 | ;; "If a relative-directory-marker precedes the directories, the directory |
---|
695 | ;; component parsed is as relative; otherwise, the directory component is |
---|
696 | ;; parsed as absolute." |
---|
697 | (deftest logical.21 |
---|
698 | (equal (pathname-directory #p"effluvia:foo.baz") |
---|
699 | #-allegro '(:absolute) |
---|
700 | #+allegro nil) |
---|
701 | t) |
---|
702 | |
---|
703 | (deftest logical.22 |
---|
704 | (typep #p"effluvia:" 'logical-pathname) |
---|
705 | t) |
---|
706 | |
---|
707 | (deftest logical.23 |
---|
708 | (equal (pathname-directory #p"effluvia:") |
---|
709 | #-allegro '(:absolute) |
---|
710 | #+allegro nil) |
---|
711 | t) |
---|
712 | |
---|
713 | ;; PARSE-NAMESTRING |
---|
714 | (deftest parse-namestring.1 |
---|
715 | #-allegro |
---|
716 | (check-logical-pathname (parse-namestring "effluvia:foo.bar") |
---|
717 | "EFFLUVIA" '(:absolute) "FOO" "BAR" nil) |
---|
718 | #+allegro |
---|
719 | (check-logical-pathname (parse-namestring "effluvia:foo.bar") |
---|
720 | "effluvia" nil "foo" "bar" nil) |
---|
721 | t) |
---|
722 | |
---|
723 | (deftest parse-namestring.2 |
---|
724 | (let ((pathname (parse-namestring "foo.bar" "effluvia"))) |
---|
725 | #-(or allegro lispworks) |
---|
726 | (check-logical-pathname pathname "EFFLUVIA" '(:absolute) "FOO" "BAR" nil) |
---|
727 | #+allegro |
---|
728 | (check-logical-pathname pathname "effluvia" nil "foo" "bar" nil) |
---|
729 | #+lispworks |
---|
730 | (check-logical-pathname pathname "effluvia" '(:absolute) "FOO" "BAR" nil)) |
---|
731 | t) |
---|
732 | |
---|
733 | (deftest parse-namestring.3 |
---|
734 | (let ((pathname (parse-namestring "foo;bar;baz.fas.3" "effluvia"))) |
---|
735 | #-(or allegro lispworks) |
---|
736 | (check-logical-pathname pathname "EFFLUVIA" '(:absolute "FOO" "BAR") "BAZ" "FAS" 3) |
---|
737 | #+allegro |
---|
738 | (check-logical-pathname pathname "effluvia" '(:absolute "foo" "bar") "baz" "fas" nil) |
---|
739 | #+lispworks |
---|
740 | (check-logical-pathname pathname "effluvia" '(:absolute "FOO" "BAR") "BAZ" "FAS" 3) |
---|
741 | ) |
---|
742 | t) |
---|
743 | |
---|
744 | (deftest parse-namestring.4 |
---|
745 | #-(or abcl clisp cmu lispworks (and allegro windows)) |
---|
746 | (check-physical-pathname (parse-namestring "effluvia:foo.bar" "") |
---|
747 | nil "effluvia:foo" "bar") |
---|
748 | #+abcl |
---|
749 | ;; Invalid logical host name: "" |
---|
750 | (signals-error (parse-namestring "effluvia:foo.bar" "") 'error) |
---|
751 | #+(or clisp lispworks) |
---|
752 | ;; Host mismatch. |
---|
753 | (signals-error (parse-namestring "effluvia:foo.bar" "") 'error) |
---|
754 | #+cmu |
---|
755 | (signals-error (parse-namestring "effluvia:foo.bar" "") 'error) |
---|
756 | #+(and allegro windows) |
---|
757 | ;; "effluvia" is the device |
---|
758 | (check-physical-pathname (parse-namestring "effluvia:foo.bar" "") |
---|
759 | nil "foo" "bar") |
---|
760 | t) |
---|
761 | |
---|
762 | ;; "If host is nil and thing is a syntactically valid logical pathname |
---|
763 | ;; namestring containing an explicit host, then it is parsed as a logical |
---|
764 | ;; pathname namestring." |
---|
765 | (deftest parse-namestring.5 |
---|
766 | #-allegro |
---|
767 | (check-logical-pathname (parse-namestring "effluvia:foo.bar" nil) |
---|
768 | "EFFLUVIA" '(:absolute) "FOO" "BAR" nil) |
---|
769 | #+allegro |
---|
770 | (check-logical-pathname (parse-namestring "effluvia:foo.bar" nil) |
---|
771 | "effluvia" nil "foo" "bar" nil) |
---|
772 | t) |
---|
773 | |
---|
774 | ;; "If host is nil, default-pathname is a logical pathname, and thing is a |
---|
775 | ;; syntactically valid logical pathname namestring without an explicit host, |
---|
776 | ;; then it is parsed as a logical pathname namestring on the host that is the |
---|
777 | ;; host component of default-pathname." |
---|
778 | (deftest parse-namestring.6 |
---|
779 | #-allegro |
---|
780 | (check-logical-pathname (parse-namestring "foo" nil #p"effluvia:bar") |
---|
781 | "EFFLUVIA" '(:absolute) "FOO" nil nil) |
---|
782 | #+allegro |
---|
783 | (check-logical-pathname (parse-namestring "foo" nil #p"effluvia:bar") |
---|
784 | "effluvia" nil "foo" nil nil) |
---|
785 | t) |
---|
786 | |
---|
787 | (deftest parse-namestring.7 |
---|
788 | (let* ((*default-pathname-defaults* (logical-pathname "EFFLUVIA:")) |
---|
789 | (pathname (parse-namestring "foo.bar"))) |
---|
790 | #-allegro |
---|
791 | (check-logical-pathname pathname "EFFLUVIA" '(:absolute) "FOO" "BAR" nil) |
---|
792 | #+allegro |
---|
793 | (check-logical-pathname pathname "effluvia" nil "foo" "bar" nil)) |
---|
794 | t) |
---|
795 | |
---|
796 | (deftest parse-namestring.8 |
---|
797 | (let* ((*default-pathname-defaults* #p"effluvia:bar") |
---|
798 | (pathname (parse-namestring "foo" nil))) |
---|
799 | #-allegro |
---|
800 | (check-logical-pathname pathname "EFFLUVIA" '(:absolute) "FOO" nil nil) |
---|
801 | #+allegro |
---|
802 | (check-logical-pathname pathname "effluvia" nil "foo" nil nil)) |
---|
803 | t) |
---|
804 | |
---|
805 | ;; WILD-PATHNAME-P |
---|
806 | (deftest wild-pathname-p.1 |
---|
807 | (wild-pathname-p #p"effluvia:;*.baz") |
---|
808 | #+(or cmu sbcl) (:wild :wild-inferiors) |
---|
809 | #-(or cmu sbcl) t) |
---|
810 | |
---|
811 | ;; PATHNAME-MATCH-P |
---|
812 | (deftest pathname-match-p.1 |
---|
813 | (pathname-match-p "/foo/bar/baz" "/*/*/baz") |
---|
814 | t) |
---|
815 | |
---|
816 | (deftest pathname-match-p.2 |
---|
817 | (pathname-match-p "/foo/bar/baz" "/**/baz") |
---|
818 | t) |
---|
819 | |
---|
820 | (deftest pathname-match-p.3 |
---|
821 | (pathname-match-p "/foo/bar/quux/baz" "/**/baz") |
---|
822 | t) |
---|
823 | |
---|
824 | (deftest pathname-match-p.4 |
---|
825 | (pathname-match-p "foo.bar" "/**/*.*") |
---|
826 | t) |
---|
827 | |
---|
828 | (deftest pathname-match-p.5 |
---|
829 | (pathname-match-p "/usr/local/bin/foo.bar" "/**/foo.bar") |
---|
830 | t) |
---|
831 | |
---|
832 | (deftest pathname-match-p.6 |
---|
833 | (pathname-match-p "/usr/local/bin/foo.bar" "**/foo.bar") |
---|
834 | nil) |
---|
835 | |
---|
836 | (deftest pathname-match-p.7 |
---|
837 | (pathname-match-p "/foo/bar.txt" "/**/*.*") |
---|
838 | t) |
---|
839 | |
---|
840 | (deftest pathname-match-p.8 |
---|
841 | (pathname-match-p "/foo/bar.txt" "**/*.*") |
---|
842 | nil) |
---|
843 | |
---|
844 | (deftest pathname-match-p.9 |
---|
845 | (pathname-match-p #p"effluvia:foo.bar" #p"effluvia:**;*.*.*") |
---|
846 | t) |
---|
847 | |
---|
848 | (deftest pathname-match-p.10 |
---|
849 | (pathname-match-p "foo" "foo.*") |
---|
850 | t) |
---|
851 | |
---|
852 | ;; TRANSLATE-PATHNAME |
---|
853 | (deftest translate-pathname.1 |
---|
854 | #-clisp |
---|
855 | (equal (translate-pathname "foo" "*" "bar") #p"bar") |
---|
856 | #+clisp |
---|
857 | (signals-error (translate-pathname "foo" "*" "bar") 'error) |
---|
858 | t) |
---|
859 | |
---|
860 | (deftest translate-pathname.2 |
---|
861 | (equal (translate-pathname "foo" "*" "*") #p"foo") |
---|
862 | t) |
---|
863 | |
---|
864 | (deftest translate-pathname.3 |
---|
865 | #-abcl |
---|
866 | (string= (pathname-name (translate-pathname "foobar" "*" "foo*")) |
---|
867 | #-allegro-v7.0 "foofoobar" |
---|
868 | #+allegro-v7.0 "foo*") |
---|
869 | #+abcl |
---|
870 | ;; ABCL doesn't implement this translation. Verify that it signals an error. |
---|
871 | (signals-error (translate-pathname "foobar" "*" "foo*") 'error) |
---|
872 | t) |
---|
873 | |
---|
874 | (deftest translate-pathname.4 |
---|
875 | #-abcl |
---|
876 | (equal (translate-pathname "foobar" "foo*" "*baz") |
---|
877 | #-allegro-v7.0 #p"barbaz" |
---|
878 | #+allegro-v7.0 #p"*baz") |
---|
879 | #+abcl |
---|
880 | ;; ABCL doesn't implement this translation. Verify that it signals an error. |
---|
881 | (signals-error (translate-pathname "foobar" "foo*" "*baz") 'error) |
---|
882 | t) |
---|
883 | |
---|
884 | (deftest translate-pathname.5 |
---|
885 | #-abcl |
---|
886 | (equal (translate-pathname "foobar" "foo*" "") |
---|
887 | #+(or allegro clisp) #p"bar" |
---|
888 | #+(or cmu sbcl lispworks) #p"foobar") |
---|
889 | #+abcl |
---|
890 | ;; ABCL doesn't implement this translation. Verify that it signals an error. |
---|
891 | (signals-error (translate-pathname "foobar" "foo*" "") 'error) |
---|
892 | t) |
---|
893 | |
---|
894 | (deftest translate-pathname.6 |
---|
895 | (equal (translate-pathname "foo/bar" "*/bar" "*/baz") #p"foo/baz") |
---|
896 | t) |
---|
897 | |
---|
898 | (deftest translate-pathname.7 |
---|
899 | (equal (translate-pathname "bar/foo" "bar/*" "baz/*") #p"baz/foo") |
---|
900 | t) |
---|
901 | |
---|
902 | (deftest translate-pathname.8 |
---|
903 | (equal (translate-pathname "foo/bar" "*/bar" "*/baz") #p"foo/baz") |
---|
904 | t) |
---|
905 | |
---|
906 | (deftest translate-pathname.9 |
---|
907 | (string= (namestring (translate-pathname "test.txt" "*.txt" "*.text")) |
---|
908 | "test.text") |
---|
909 | t) |
---|
910 | |
---|
911 | (deftest translate-pathname.10 |
---|
912 | (equal (translate-pathname "foo" "foo.*" "bar") #p"bar") |
---|
913 | t) |
---|
914 | |
---|
915 | (deftest translate-pathname.11 |
---|
916 | (equal (translate-pathname "foo" "foo.*" "bar.*") #p"bar") |
---|
917 | t) |
---|
918 | |
---|
919 | (deftest translate-pathname.12 |
---|
920 | (string= (namestring (translate-pathname "foo.bar" "*.*" "/usr/local/*.*")) |
---|
921 | #-windows "/usr/local/foo.bar" |
---|
922 | #+windows "\\usr\\local\\foo.bar") |
---|
923 | t) |
---|
924 | |
---|
925 | (deftest translate-pathname.13 |
---|
926 | (equal (translate-pathname "foo.bar" "*.*" "/usr/local/*.*") |
---|
927 | #p"/usr/local/foo.bar") |
---|
928 | t) |
---|
929 | |
---|
930 | (deftest translate-pathname.14 |
---|
931 | (check-translate-pathname '("/foo/" "/*/" "/usr/local/*/") "/usr/local/foo/") |
---|
932 | t) |
---|
933 | |
---|
934 | (deftest translate-pathname.15 |
---|
935 | (check-translate-pathname '("/foo/baz/bar.txt" "/**/*.*" "/usr/local/**/*.*") |
---|
936 | "/usr/local/foo/baz/bar.txt") |
---|
937 | t) |
---|
938 | |
---|
939 | (deftest translate-pathname.16 |
---|
940 | (equal (translate-pathname "/foo/" "/*/" "/usr/local/*/bar/") #p"/usr/local/foo/bar/") |
---|
941 | t) |
---|
942 | |
---|
943 | (deftest translate-pathname.17 |
---|
944 | (equal (translate-pathname "/foo/bar.txt" "/*/*.*" "/usr/local/*/*.*") |
---|
945 | #P"/usr/local/foo/bar.txt") |
---|
946 | t) |
---|
947 | |
---|
948 | ;; "TRANSLATE-PATHNAME translates SOURCE (that matches FROM-WILDCARD)..." |
---|
949 | (deftest pathname-match-p.11 |
---|
950 | (pathname-match-p "/foo/bar.txt" "**/*.*") |
---|
951 | nil) |
---|
952 | |
---|
953 | ;; Since (pathname-match-p "/foo/bar.txt" "**/*.*" ) => NIL... |
---|
954 | (deftest translate-pathname.18 |
---|
955 | #+(or clisp allegro abcl cmu lispworks) |
---|
956 | ;; This seems to be the correct behavior. |
---|
957 | (signals-error (translate-pathname "/foo/bar.txt" "**/*.*" "/usr/local/**/*.*") 'error) |
---|
958 | #+sbcl |
---|
959 | ;; This appears to be a bug, since SOURCE doesn't match FROM-WILDCARD. |
---|
960 | (equal (translate-pathname "/foo/bar.txt" "**/*.*" "/usr/local/**/*.*") |
---|
961 | #p"/usr/local/foo/bar.txt") |
---|
962 | t) |
---|
963 | |
---|
964 | (deftest pathname-match-p.12 |
---|
965 | (pathname-match-p "/foo/bar.txt" "/**/*.*") |
---|
966 | t) |
---|
967 | |
---|
968 | (deftest translate-pathname.19 |
---|
969 | (equal (translate-pathname "/foo/bar.txt" "/**/*.*" "/usr/local/**/*.*") |
---|
970 | #p"/usr/local/foo/bar.txt") |
---|
971 | t) |
---|
972 | |
---|
973 | #-clisp |
---|
974 | (deftest translate-pathname.20 |
---|
975 | (equal (translate-pathname "foo.bar" "/**/*.*" "/usr/local/") #p"/usr/local/foo.bar") |
---|
976 | t) |
---|
977 | |
---|
978 | ;; TRANSLATE-LOGICAL-PATHNAME |
---|
979 | |
---|
980 | ;; "PATHNAME is first coerced to a pathname. If the coerced pathname is a |
---|
981 | ;; physical pathname, it is returned." |
---|
982 | (deftest translate-logical-pathname.1 |
---|
983 | (equal (translate-logical-pathname #p"/") #p"/") |
---|
984 | t) |
---|
985 | |
---|
986 | #+(or abcl clisp) |
---|
987 | (deftest translate-logical-pathname.2 |
---|
988 | (equal (translate-logical-pathname "effluvia:foo.bar") #p"/usr/local/foo.bar") |
---|
989 | t) |
---|
990 | |
---|
991 | #+(or sbcl cmu) |
---|
992 | (deftest translate-logical-pathname.3 |
---|
993 | ;; Device mismatch. |
---|
994 | (and (eq (pathname-device (translate-logical-pathname "effluvia:foo.bar")) |
---|
995 | :unspecific) |
---|
996 | (eq (pathname-device #p"/usr/local/foo/bar") |
---|
997 | nil)) |
---|
998 | t) |
---|
999 | |
---|
1000 | (deftest translate-logical-pathname.4 |
---|
1001 | (check-namestring (translate-logical-pathname "effluvia:foo.bar") |
---|
1002 | "/usr/local/foo.bar") |
---|
1003 | t) |
---|
1004 | |
---|
1005 | (deftest translate-logical-pathname.5 |
---|
1006 | (check-namestring (translate-logical-pathname "effluvia:foo;bar.txt") |
---|
1007 | "/usr/local/foo/bar.txt") |
---|
1008 | t) |
---|
1009 | |
---|
1010 | (deftest translate-logical-pathname.6 |
---|
1011 | #-allegro |
---|
1012 | (check-logical-pathname #p"effluvia:Foo.Bar" "EFFLUVIA" '(:absolute) "FOO" "BAR" nil) |
---|
1013 | #+allegro |
---|
1014 | ;; Allegro preserves case. |
---|
1015 | (check-logical-pathname #p"effluvia:Foo.Bar" "effluvia" nil "Foo" "Bar" nil) |
---|
1016 | t) |
---|
1017 | |
---|
1018 | ;; "TRANSLATE-PATHNAME [and thus also TRANSLATE-LOGICAL-PATHNAME] maps |
---|
1019 | ;; customary case in SOURCE into customary case in the output pathname." |
---|
1020 | (deftest translate-logical-pathname.7 |
---|
1021 | #-allegro |
---|
1022 | (check-physical-pathname (translate-logical-pathname #p"effluvia:Foo.Bar") |
---|
1023 | '(:absolute "usr" "local") "foo" "bar") |
---|
1024 | #+allegro |
---|
1025 | ;; Allegro preserves case. |
---|
1026 | (check-physical-pathname (translate-logical-pathname #p"effluvia:Foo.Bar") |
---|
1027 | '(:absolute "usr" "local") "Foo" "Bar") |
---|
1028 | t) |
---|
1029 | |
---|
1030 | (deftest merge-pathnames.1 |
---|
1031 | #-allegro |
---|
1032 | (check-logical-pathname (merge-pathnames "effluvia:foo.bar") |
---|
1033 | "EFFLUVIA" '(:absolute) "FOO" "BAR" :newest) |
---|
1034 | #+allegro |
---|
1035 | ;; Allegro's MERGE-PATHNAMES apparently calls TRANSLATE-LOGICAL-PATHNAME. |
---|
1036 | (check-physical-pathname (merge-pathnames "effluvia:foo.bar") |
---|
1037 | '(:absolute "usr" "local") "foo" "bar") |
---|
1038 | t) |
---|
1039 | |
---|
1040 | (deftest merge-pathnames.2 |
---|
1041 | (equal (merge-pathnames (logical-pathname "effluvia:;foo;bar;") |
---|
1042 | (logical-pathname "effluvia:baz;quux.lisp.3")) |
---|
1043 | #-allegro |
---|
1044 | (make-pathname :host "EFFLUVIA" |
---|
1045 | :device :unspecific |
---|
1046 | :directory '(:absolute "BAZ" "FOO" "BAR") |
---|
1047 | :name "QUUX" |
---|
1048 | :type "LISP" |
---|
1049 | :version 3) |
---|
1050 | #+allegro |
---|
1051 | (make-pathname :host "effluvia" |
---|
1052 | :device nil |
---|
1053 | :directory '(:absolute "baz" "foo" "bar") |
---|
1054 | :name "quux" |
---|
1055 | :type "lisp" |
---|
1056 | :version nil) |
---|
1057 | ) |
---|
1058 | t) |
---|
1059 | |
---|
1060 | (deftest compile-file-pathname.1 |
---|
1061 | (equal (compile-file-pathname "effluvia:foo.lisp") |
---|
1062 | #+abcl |
---|
1063 | ;; Is this a bug? (Should version be :NEWEST?) |
---|
1064 | #p"EFFLUVIA:FOO.ABCL" |
---|
1065 | #+allegro #p"effluvia:foo.fasl" |
---|
1066 | #+(or cmu sbcl) #p"EFFLUVIA:FOO.FASL.NEWEST" |
---|
1067 | #+clisp |
---|
1068 | ;; Is this a bug? |
---|
1069 | ;; #p"EFFLUVIA:FOO.fas.NEWEST" |
---|
1070 | (make-pathname :host "EFFLUVIA" :directory '(:absolute) |
---|
1071 | :name "FOO" :type "fas" :version :newest) |
---|
1072 | #+(and lispworks unix) #p"EFFLUVIA:FOO.UFSL.NEWEST" |
---|
1073 | #+(and lispworks windows) #p"EFFLUVIA:FOO.FSL.NEWEST") |
---|
1074 | t) |
---|
1075 | |
---|
1076 | (deftest file-namestring.1 |
---|
1077 | (equal (file-namestring #p"") |
---|
1078 | #+(or abcl allegro cmu) |
---|
1079 | nil |
---|
1080 | #+(or clisp lispworks sbcl) |
---|
1081 | "") |
---|
1082 | t) |
---|
1083 | |
---|
1084 | (deftest file-namestring.2 |
---|
1085 | (equal (file-namestring #p"foo") "foo") |
---|
1086 | t) |
---|
1087 | |
---|
1088 | (deftest file-namestring.3 |
---|
1089 | (let ((pathname (make-pathname :type "foo"))) |
---|
1090 | #+abcl |
---|
1091 | (equal (file-namestring pathname) nil) |
---|
1092 | #+allegro |
---|
1093 | (equal (file-namestring pathname) "NIL.foo") ;; bug |
---|
1094 | #+(or clisp lispworks) |
---|
1095 | (equal (file-namestring pathname) ".foo") |
---|
1096 | #+(or cmu sbcl) |
---|
1097 | (signals-error (file-namestring pathname) 'error)) |
---|
1098 | t) |
---|
1099 | |
---|
1100 | ;; A variant of FILE-NAMESTRING.3 that detects Allegro's bug as a bug. |
---|
1101 | (deftest file-namestring.4 |
---|
1102 | (let ((pathname (make-pathname :type "foo"))) |
---|
1103 | #-(or cmu sbcl) |
---|
1104 | (not (equal (file-namestring pathname) "NIL.foo")) |
---|
1105 | #+(or cmu sbcl) |
---|
1106 | (signals-error (file-namestring pathname) 'error)) |
---|
1107 | t) |
---|
1108 | #+allegro |
---|
1109 | (pushnew 'file-namestring.4 *expected-failures*) |
---|
1110 | |
---|
1111 | (deftest enough-namestring.1 |
---|
1112 | (equal (enough-namestring #p"/foo" #p"/") "foo") |
---|
1113 | t) |
---|
1114 | #+sbcl |
---|
1115 | (pushnew 'enough-namestring.1 *expected-failures*) |
---|
1116 | |
---|
1117 | (deftest enough-namestring.2 |
---|
1118 | #-windows |
---|
1119 | (equal (enough-namestring #p"foo/bar" #p"foo") "foo/bar") |
---|
1120 | #+windows |
---|
1121 | (equal (enough-namestring #p"foo\\bar" #p"foo") "foo\\bar") |
---|
1122 | t) |
---|
1123 | |
---|
1124 | (deftest enough-namestring.3 |
---|
1125 | (equal (enough-namestring #p"foo/bar" #p"foo/") "bar") |
---|
1126 | t) |
---|
1127 | #+sbcl |
---|
1128 | (pushnew 'enough-namestring.3 *expected-failures*) |
---|
1129 | |
---|
1130 | ;; The following tests are adapted from SBCL's pathnames.impure.lisp. |
---|
1131 | (setf (logical-pathname-translations "demo0") |
---|
1132 | '(("**;*.*.*" "/tmp/"))) |
---|
1133 | (deftest sbcl.1 |
---|
1134 | (pathname-match-p "demo0:file.lisp" (logical-pathname "demo0:tmp;**;*.*.*")) |
---|
1135 | nil) |
---|
1136 | |
---|
1137 | #-clisp |
---|
1138 | (deftest sbcl.2 |
---|
1139 | (check-namestring (translate-logical-pathname "demo0:file.lisp") "/tmp/file.lisp") |
---|
1140 | t) |
---|
1141 | |
---|
1142 | (setf (logical-pathname-translations "demo1") |
---|
1143 | '(("**;*.*.*" "/tmp/**/*.*") (";**;*.*.*" "/tmp/rel/**/*.*"))) |
---|
1144 | ;; Remove "**" from the resulting pathname when the source directory is NIL. |
---|
1145 | (deftest sbcl.3 |
---|
1146 | (equal (namestring (translate-logical-pathname "demo1:foo.lisp")) |
---|
1147 | #-windows "/tmp/**/foo.lisp" |
---|
1148 | #+windows "\\tmp\\**\\foo.lisp") |
---|
1149 | nil) |
---|
1150 | |
---|
1151 | (deftest sbcl.4 |
---|
1152 | (check-namestring (translate-logical-pathname "demo1:foo.lisp") "/tmp/foo.lisp") |
---|
1153 | t) |
---|
1154 | |
---|
1155 | ;;; Check for absolute/relative path confusion. |
---|
1156 | #-allegro |
---|
1157 | (deftest sbcl.5 |
---|
1158 | (pathname-match-p "demo1:;foo.lisp" "demo1:**;*.*.*") |
---|
1159 | nil) |
---|
1160 | |
---|
1161 | #+(or sbcl cmu) |
---|
1162 | ;; BUG Pathnames should match if the following translation is to work. |
---|
1163 | (deftest sbcl.6 |
---|
1164 | (pathname-match-p "demo1:;foo.lisp" "demo1:;**;*.*.*") |
---|
1165 | t) |
---|
1166 | |
---|
1167 | #+clisp |
---|
1168 | (deftest sbcl.7 |
---|
1169 | (pathname-match-p "demo1:;foo.lisp" ";**;*.*.*") |
---|
1170 | t) |
---|
1171 | |
---|
1172 | (deftest sbcl.8 |
---|
1173 | (check-namestring (translate-logical-pathname "demo1:;foo.lisp") |
---|
1174 | #+abcl "/tmp/rel/foo.lisp" |
---|
1175 | #+allegro "/tmp/foo.lisp" |
---|
1176 | #-(or allegro abcl) "/tmp/rel/foo.lisp") |
---|
1177 | t) |
---|
1178 | |
---|
1179 | (setf (logical-pathname-translations "demo2") |
---|
1180 | '(("test;**;*.*" "/tmp/demo2/test"))) |
---|
1181 | |
---|
1182 | (deftest sbcl.9 |
---|
1183 | (equal (enough-namestring "demo2:test;foo.lisp") |
---|
1184 | #+sbcl "DEMO2:;TEST;FOO.LISP" |
---|
1185 | #+(or abcl cmu lispworks) "DEMO2:TEST;FOO.LISP" |
---|
1186 | #+allegro-v7.0 "demo2:test;foo.lisp" |
---|
1187 | #+allegro-v6.2 "/test/foo.lisp" ;; BUG |
---|
1188 | #+(and clisp unix) "TEST;FOO.LISP" |
---|
1189 | #+(and clisp windows) "DEMO2:TEST;FOO.LISP") |
---|
1190 | t) |
---|
1191 | |
---|
1192 | #-(or allegro clisp cmu) |
---|
1193 | (deftest sbcl.10 |
---|
1194 | (signals-error (make-pathname :host "EFFLUVIA" :directory "!bla" :name "bar") |
---|
1195 | 'error) |
---|
1196 | t) |
---|
1197 | #-(or allegro cmu) |
---|
1198 | (deftest sbcl.11 |
---|
1199 | (signals-error (make-pathname :host "EFFLUVIA" :directory "bla" :name "!bar") |
---|
1200 | 'error) |
---|
1201 | t) |
---|
1202 | #-(or allegro cmu) |
---|
1203 | (deftest sbcl.12 |
---|
1204 | (signals-error (make-pathname :host "EFFLUVIA" :directory "bla" :name "bar" :type "&baz") |
---|
1205 | 'error) |
---|
1206 | t) |
---|
1207 | |
---|
1208 | (deftest sbcl.13 |
---|
1209 | (equal (namestring (parse-namestring "" "EFFLUVIA")) "EFFLUVIA:") |
---|
1210 | t) |
---|
1211 | |
---|
1212 | (deftest sbcl.14 |
---|
1213 | #-cmu |
---|
1214 | (equal (namestring (parse-namestring "" :unspecific)) "") |
---|
1215 | #+cmu |
---|
1216 | ;; It seems reasonable to signal an error here, since the HOST argument to |
---|
1217 | ;; PARSE-NAMESTRING is specified to be "a valid pathname host, a logical host, |
---|
1218 | ;; or NIL". |
---|
1219 | (signals-error (parse-namestring "" :unspecific) 'type-error) |
---|
1220 | t) |
---|
1221 | |
---|
1222 | (deftest sbcl.15 |
---|
1223 | (equal (namestring (parse-namestring "" |
---|
1224 | (pathname-host |
---|
1225 | (translate-logical-pathname |
---|
1226 | "EFFLUVIA:")))) |
---|
1227 | "") |
---|
1228 | t) |
---|
1229 | |
---|
1230 | ;; PARSE-NAMESTRING host mismatch: "If HOST is supplied and not NIL, and THING |
---|
1231 | ;; contains a manifest host name, an error of type ERROR is signaled if the |
---|
1232 | ;; hosts do not match." |
---|
1233 | (deftest sbcl.16 |
---|
1234 | (signals-error (parse-namestring "effluvia:foo.bar" "demo2") 'error) |
---|
1235 | t) |
---|
1236 | |
---|
1237 | (setf (logical-pathname-translations "bazooka") |
---|
1238 | '(("todemo;*.*.*" "demo0:*.*.*"))) |
---|
1239 | |
---|
1240 | (deftest sbcl.17 |
---|
1241 | #+allegro ;; BUG |
---|
1242 | (check-namestring (translate-logical-pathname "bazooka:todemo;x.y") "/tmp/todemo/x.y") |
---|
1243 | #+clisp ;; BUG |
---|
1244 | (signals-error (translate-logical-pathname "bazooka:todemo;x.y") 'error) |
---|
1245 | #-(or allegro clisp) |
---|
1246 | (check-namestring (translate-logical-pathname "bazooka:todemo;x.y") "/tmp/x.y") |
---|
1247 | t) |
---|
1248 | |
---|
1249 | (deftest sbcl.18 |
---|
1250 | #+clisp ;; BUG |
---|
1251 | (signals-error (translate-logical-pathname "demo0:x.y") 'error) |
---|
1252 | #-clisp |
---|
1253 | (equal (namestring (translate-logical-pathname "demo0:x.y")) |
---|
1254 | #-windows "/tmp/x.y" |
---|
1255 | #+windows "\\tmp\\x.y") |
---|
1256 | t) |
---|
1257 | |
---|
1258 | #-(or allegro clisp) |
---|
1259 | (deftest sbcl.19 |
---|
1260 | (equal (namestring (translate-logical-pathname "bazooka:todemo;x.y")) |
---|
1261 | (namestring (translate-logical-pathname "demo0:x.y"))) |
---|
1262 | t) |
---|
1263 | |
---|
1264 | ;; "If HOST is incorrectly supplied, an error of type TYPE-ERROR is signaled." |
---|
1265 | (deftest sbcl.20 |
---|
1266 | (signals-error (logical-pathname-translations "unregistered-host") |
---|
1267 | #+(or clisp lispworks) 'error ;; BUG |
---|
1268 | #+cmu 'file-error ;; BUG |
---|
1269 | #-(or clisp lispworks cmu) 'type-error) |
---|
1270 | t) |
---|
1271 | |
---|
1272 | (deftest sbcl.21 |
---|
1273 | (string-equal (host-namestring (parse-namestring "OTHER-HOST:ILLEGAL/LPN")) "OTHER-HOST") |
---|
1274 | nil) |
---|
1275 | #+(or lispworks (and clisp windows)) |
---|
1276 | (pushnew 'sbcl.21 *expected-failures*) |
---|
1277 | |
---|
1278 | (deftest sbcl.22 |
---|
1279 | (string= (pathname-name (parse-namestring "OTHER-HOST:ILLEGAL/LPN")) "LPN") |
---|
1280 | t) |
---|
1281 | #+(and clisp windows) |
---|
1282 | (pushnew 'sbcl.22 *expected-failures*) |
---|
1283 | |
---|
1284 | (setf (logical-pathname-translations "test0") |
---|
1285 | '(("**;*.*.*" "/library/foo/**/"))) |
---|
1286 | |
---|
1287 | (deftest sbcl.23 |
---|
1288 | (check-namestring (translate-logical-pathname "test0:foo;bar;baz;mum.quux") |
---|
1289 | "/library/foo/foo/bar/baz/mum.quux") |
---|
1290 | t) |
---|
1291 | |
---|
1292 | (setf (logical-pathname-translations "prog") |
---|
1293 | '(("CODE;*.*.*" "/lib/prog/"))) |
---|
1294 | |
---|
1295 | #-allegro |
---|
1296 | (deftest sbcl.24 |
---|
1297 | (check-namestring (translate-logical-pathname "prog:code;documentation.lisp") |
---|
1298 | "/lib/prog/documentation.lisp") |
---|
1299 | t) |
---|
1300 | |
---|
1301 | (setf (logical-pathname-translations "prog1") |
---|
1302 | '(("CODE;DOCUMENTATION.*.*" "/lib/prog/docum.*") |
---|
1303 | ("CODE;*.*.*" "/lib/prog/"))) |
---|
1304 | |
---|
1305 | #-allegro |
---|
1306 | (deftest sbcl.25 |
---|
1307 | (check-namestring (translate-logical-pathname "prog1:code;documentation.lisp") |
---|
1308 | "/lib/prog/docum.lisp") |
---|
1309 | t) |
---|
1310 | |
---|
1311 | ;; "ANSI section 19.3.1.1.5 specifies that translation to a filesystem which |
---|
1312 | ;; doesn't have versions should ignore the version slot. CMU CL didn't ignore |
---|
1313 | ;; this as it should, but we [i.e. SBCL] do." |
---|
1314 | ;; "Some file systems do not have versions. Logical pathname translation to |
---|
1315 | ;; such a file system ignores the version." 19.3.1.1.5 |
---|
1316 | #-cmu |
---|
1317 | ;; CMUCL supports emacs-style versions. |
---|
1318 | (deftest sbcl.26 |
---|
1319 | (check-namestring (translate-logical-pathname "test0:foo;bar;baz;mum.quux.3") |
---|
1320 | "/library/foo/foo/bar/baz/mum.quux") |
---|
1321 | t) |
---|
1322 | #+lispworks |
---|
1323 | (pushnew 'sbcl.26 *expected-failures*) |
---|
1324 | |
---|
1325 | (setf (logical-pathname-translations "scratch") |
---|
1326 | '(("**;*.*.*" "/usr/local/doc/**/*"))) |
---|
1327 | |
---|
1328 | ;; Trivial merge. |
---|
1329 | (deftest sbcl.27 |
---|
1330 | (check-merge-pathnames #p"foo" #p"/usr/local/doc/" #p"/usr/local/doc/foo") |
---|
1331 | t) |
---|
1332 | |
---|
1333 | ;; If pathname does not specify a host, device, directory, name, or type, each |
---|
1334 | ;; such component is copied from default-pathname. |
---|
1335 | ;; 1) no name, no type |
---|
1336 | (deftest sbcl.28 |
---|
1337 | (check-merge-pathnames #p"/supplied-dir/" #p"/dir/name.type" |
---|
1338 | #p"/supplied-dir/name.type") |
---|
1339 | t) |
---|
1340 | |
---|
1341 | ;; 2) no directory, no type |
---|
1342 | (deftest sbcl.29 |
---|
1343 | (check-merge-pathnames #p"supplied-name" #p"/dir/name.type" |
---|
1344 | #p"/dir/supplied-name.type") |
---|
1345 | t) |
---|
1346 | |
---|
1347 | ;; 3) no name, no dir (must use make-pathname as ".foo" is parsed |
---|
1348 | ;; as a name) |
---|
1349 | (deftest sbcl.30 |
---|
1350 | (check-merge-pathnames (make-pathname :type "supplied-type") |
---|
1351 | #p"/dir/name.type" |
---|
1352 | #p"/dir/name.supplied-type") |
---|
1353 | t) |
---|
1354 | |
---|
1355 | ;; If (pathname-directory pathname) is a list whose car is |
---|
1356 | ;; :relative, and (pathname-directory default-pathname) is a |
---|
1357 | ;; list, then the merged directory is [...] |
---|
1358 | (deftest sbcl.31 |
---|
1359 | (check-merge-pathnames #p"qqq/www" #p"/aaa/bbb/ccc/ddd/eee" |
---|
1360 | #p"/aaa/bbb/ccc/ddd/qqq/www") |
---|
1361 | t) |
---|
1362 | |
---|
1363 | ;; except that if the resulting list contains a string or |
---|
1364 | ;; :wild immediately followed by :back, both of them are |
---|
1365 | ;; removed. |
---|
1366 | (deftest sbcl.32 |
---|
1367 | (check-merge-pathnames |
---|
1368 | ;; "../" in a namestring is parsed as :up not :back, so MAKE-PATHNAME. |
---|
1369 | (make-pathname :directory '(:relative :back "blah")) |
---|
1370 | #p"/aaa/bbb/ccc/ddd/eee" #P"/aaa/bbb/ccc/blah/eee") |
---|
1371 | t) |
---|
1372 | |
---|
1373 | ;; If (pathname-directory default-pathname) is not a list or |
---|
1374 | ;; (pathname-directory pathname) is not a list whose car is |
---|
1375 | ;; :relative, the merged directory is (or (pathname-directory |
---|
1376 | ;; pathname) (pathname-directory default-pathname)) |
---|
1377 | (deftest sbcl.33 |
---|
1378 | (check-merge-pathnames #p"/absolute/path/name" #p"/dir/default-name.type" |
---|
1379 | #P"/absolute/path/name.type") |
---|
1380 | t) |
---|
1381 | |
---|
1382 | (deftest sbcl.34 |
---|
1383 | (check-merge-pathnames #p"scratch:;name2" #p"scratch:foo;" |
---|
1384 | #p"SCRATCH:FOO;NAME2") |
---|
1385 | t) |
---|
1386 | |
---|
1387 | (deftest sbcl.35 |
---|
1388 | (check-merge-pathnames #p"scratch:;foo" #p"/usr/local/doc/" |
---|
1389 | #-(or allegro clisp lispworks) #P"SCRATCH:USR;LOCAL;DOC;FOO" |
---|
1390 | #+(and allegro unix) #p"/usr/local/doc/foo" |
---|
1391 | #+(and allegro windows) #p"scratch:usr;local;doc;foo" |
---|
1392 | #+clisp #p"SCRATCH:;FOO" |
---|
1393 | #+lispworks #p"SCRATCH:FOO") |
---|
1394 | t) |
---|
1395 | |
---|
1396 | (deftest sbcl.36 |
---|
1397 | (check-merge-pathnames #p"scratch:supplied-dir;" #p"/dir/name.type" |
---|
1398 | #-clisp #p"SCRATCH:SUPPLIED-DIR;NAME.TYPE" |
---|
1399 | #+clisp |
---|
1400 | ;; #p"SCRATCH:SUPPLIED-DIR;name.type.NEWEST" |
---|
1401 | (make-pathname :host "SCRATCH" |
---|
1402 | :directory '(:absolute "SUPPLIED-DIR") |
---|
1403 | :name "name" |
---|
1404 | :type "type")) |
---|
1405 | t) |
---|
1406 | |
---|
1407 | (deftest sbcl.37 |
---|
1408 | (check-merge-pathnames #p"scratch:;supplied-name" #p"/dir/name.type" |
---|
1409 | #-(or allegro clisp lispworks) |
---|
1410 | #p"SCRATCH:DIR;SUPPLIED-NAME.TYPE" |
---|
1411 | #+(and allegro unix) |
---|
1412 | #p"/usr/local/doc/supplied-name.type" |
---|
1413 | #+(and allegro windows) |
---|
1414 | #P"scratch:dir;supplied-name.type" |
---|
1415 | #+clisp |
---|
1416 | ;; #P"SCRATCH:;SUPPLIED-NAME.type.NEWEST" |
---|
1417 | (make-pathname :host "SCRATCH" |
---|
1418 | :directory '(:relative) |
---|
1419 | :name "SUPPLIED-NAME" |
---|
1420 | :type "type") |
---|
1421 | #+lispworks |
---|
1422 | ;; #P"SCRATCH:SUPPLIED-NAME.TYPE.NEWEST" |
---|
1423 | (make-pathname :host "SCRATCH" |
---|
1424 | :directory '(:absolute) |
---|
1425 | :name "SUPPLIED-NAME" |
---|
1426 | :type "TYPE")) |
---|
1427 | t) |
---|
1428 | |
---|
1429 | (deftest sbcl.38 |
---|
1430 | (check-merge-pathnames (make-pathname :host "scratch" :type "supplied-type") |
---|
1431 | #p"/dir/name.type" |
---|
1432 | #-(or allegro clisp lispworks) |
---|
1433 | #p"SCRATCH:DIR;NAME.SUPPLIED-TYPE" |
---|
1434 | #+(and allegro unix) |
---|
1435 | #p"/usr/local/doc/name.supplied-type" |
---|
1436 | #+(and allegro windows) |
---|
1437 | #P"scratch:dir;name.supplied-type" |
---|
1438 | #+clisp |
---|
1439 | ;; #P"SCRATCH:dir;name.supplied-type.NEWEST" |
---|
1440 | (make-pathname :host "SCRATCH" |
---|
1441 | :directory '(:absolute "dir") |
---|
1442 | :name "name" |
---|
1443 | :type "supplied-type") |
---|
1444 | #+lispworks |
---|
1445 | ;; #P"SCRATCH:NAME.SUPPLIED-TYPE.NEWEST" |
---|
1446 | (make-pathname :host "SCRATCH" |
---|
1447 | :directory '(:absolute) |
---|
1448 | :name "NAME" |
---|
1449 | :type "SUPPLIED-TYPE")) |
---|
1450 | t) |
---|
1451 | |
---|
1452 | (deftest sbcl.39 |
---|
1453 | (let ((pathname (make-pathname :host "scratch" |
---|
1454 | :directory '(:relative "foo") |
---|
1455 | :name "bar")) |
---|
1456 | (default-pathname #p"/aaa/bbb/ccc/ddd/eee")) |
---|
1457 | #-allegro |
---|
1458 | (check-merge-pathnames pathname default-pathname |
---|
1459 | #-(or clisp lispworks) |
---|
1460 | #p"SCRATCH:AAA;BBB;CCC;DDD;FOO;BAR" |
---|
1461 | #+clisp |
---|
1462 | ;; #P"SCRATCH:;foo;bar" |
---|
1463 | (make-pathname :host "SCRATCH" |
---|
1464 | :directory '(:relative "foo") |
---|
1465 | :name "bar") |
---|
1466 | #+lispworks |
---|
1467 | #p"SCRATCH:FOO;BAR") |
---|
1468 | #+(and allegro unix) |
---|
1469 | (signals-error (merge-pathnames pathname default-pathname) 'error) |
---|
1470 | #+(and allegro windows) |
---|
1471 | (check-merge-pathnames pathname default-pathname |
---|
1472 | #P"scratch:aaa;bbb;ccc;ddd;foo;bar")) |
---|
1473 | t) |
---|
1474 | |
---|
1475 | #-lispworks |
---|
1476 | (deftest sbcl.40 |
---|
1477 | (let ((pathname (make-pathname :host "scratch" |
---|
1478 | :directory '(:relative :back "foo") |
---|
1479 | :name "bar")) |
---|
1480 | (default-pathname #p"/aaa/bbb/ccc/ddd/eee")) |
---|
1481 | #-allegro |
---|
1482 | (check-merge-pathnames pathname default-pathname |
---|
1483 | #-clisp #p"SCRATCH:AAA;BBB;CCC;FOO;BAR" |
---|
1484 | #+clisp |
---|
1485 | ;; #P"SCRATCH:;..;foo;bar.NEWEST" |
---|
1486 | (make-pathname :host "SCRATCH" |
---|
1487 | :directory '(:relative :back "foo") |
---|
1488 | :name "bar")) |
---|
1489 | #+(and allegro unix) |
---|
1490 | (signals-error (merge-pathnames pathname default-pathname) 'error) |
---|
1491 | #+(and allegro windows) |
---|
1492 | (check-merge-pathnames pathname default-pathname |
---|
1493 | #P"scratch:aaa;bbb;ccc;foo;bar")) |
---|
1494 | t) |
---|
1495 | |
---|
1496 | #+lispworks |
---|
1497 | ;; "Illegal logical pathname directory component: :BACK." |
---|
1498 | (deftest sbcl.40 |
---|
1499 | (signals-error (make-pathname :host "scratch" |
---|
1500 | :directory '(:relative :back "foo") |
---|
1501 | :name "bar") |
---|
1502 | 'error) |
---|
1503 | t) |
---|
1504 | |
---|
1505 | (deftest sbcl.41 |
---|
1506 | (check-merge-pathnames #p"scratch:absolute;path;name" |
---|
1507 | #p"/dir/default-name.type" |
---|
1508 | #-clisp #p"SCRATCH:ABSOLUTE;PATH;NAME.TYPE" |
---|
1509 | #+clisp |
---|
1510 | ;; #P"SCRATCH:ABSOLUTE;PATH;NAME.type.NEWEST" |
---|
1511 | (make-pathname :host "SCRATCH" |
---|
1512 | :directory '(:absolute "ABSOLUTE" "PATH") |
---|
1513 | :name "NAME" |
---|
1514 | :type "type")) |
---|
1515 | t) |
---|
1516 | |
---|
1517 | (deftest sbcl.42 |
---|
1518 | (check-namestring (parse-namestring "/foo" (host-namestring #p"/bar")) "/foo") |
---|
1519 | t) |
---|
1520 | #+lispworks |
---|
1521 | (pushnew 'sbcl.42 *expected-failures*) |
---|
1522 | |
---|
1523 | (deftest sbcl.43 |
---|
1524 | (string= (namestring (parse-namestring "FOO" (host-namestring #p"SCRATCH:BAR"))) |
---|
1525 | "SCRATCH:FOO") |
---|
1526 | t) |
---|
1527 | |
---|
1528 | #-(or allegro clisp cmu lispworks) |
---|
1529 | (deftest sbcl.44 |
---|
1530 | ;; "The null string, "", is not a valid value for any component of a logical |
---|
1531 | ;; pathname." 19.3.2.2 |
---|
1532 | (signals-error (setf (logical-pathname-translations "") |
---|
1533 | (list '("**;*.*.*" "/**/*.*"))) |
---|
1534 | 'error) |
---|
1535 | t) |
---|
1536 | |
---|
1537 | #-clisp |
---|
1538 | (deftest sbcl.45 |
---|
1539 | (check-namestring (translate-logical-pathname "/") "/") |
---|
1540 | t) |
---|
1541 | |
---|
1542 | (deftest sbcl.46 |
---|
1543 | (signals-error (pathname (make-string-input-stream "FOO")) |
---|
1544 | #-(or allegro-v6.2 cmu) 'type-error |
---|
1545 | #+allegro-v6.2 'stream-error |
---|
1546 | #+cmu 'error) |
---|
1547 | t) |
---|
1548 | |
---|
1549 | (deftest sbcl.47 |
---|
1550 | (signals-error (merge-pathnames (make-string-output-stream)) |
---|
1551 | #-allegro-v6.2 'type-error |
---|
1552 | #+allegro-v6.2 'stream-error) |
---|
1553 | t) |
---|
1554 | |
---|
1555 | (deftest sbcl.48 |
---|
1556 | (check-readable-or-signals-error (make-pathname :name "foo" :type "txt" :version :newest)) |
---|
1557 | t) |
---|
1558 | #+lispworks |
---|
1559 | (pushnew 'sbcl.48 *expected-failures*) |
---|
1560 | |
---|
1561 | #-allegro |
---|
1562 | (deftest sbcl.49 |
---|
1563 | (check-readable-or-signals-error (make-pathname :name "foo" :type "txt" :version 1)) |
---|
1564 | t) |
---|
1565 | #+lispworks |
---|
1566 | (pushnew 'sbcl.49 *expected-failures*) |
---|
1567 | |
---|
1568 | (deftest sbcl.50 |
---|
1569 | #-clisp |
---|
1570 | (check-readable-or-signals-error (make-pathname :name "foo" :type ".txt")) |
---|
1571 | #+clisp |
---|
1572 | (signals-error (make-pathname :name "foo" :type ".txt") 'error) |
---|
1573 | t) |
---|
1574 | #+(or allegro cmu lispworks) |
---|
1575 | (pushnew 'sbcl.50 *expected-failures*) |
---|
1576 | |
---|
1577 | (deftest sbcl.51 |
---|
1578 | (check-readable-or-signals-error (make-pathname :name "foo." :type "txt")) |
---|
1579 | t) |
---|
1580 | |
---|
1581 | (deftest sbcl.52 |
---|
1582 | (check-readable-or-signals-error (parse-namestring "SCRATCH:FOO.TXT.1")) |
---|
1583 | t) |
---|
1584 | |
---|
1585 | (deftest sbcl.53 |
---|
1586 | (check-readable-or-signals-error (parse-namestring "SCRATCH:FOO.TXT.NEWEST")) |
---|
1587 | t) |
---|
1588 | |
---|
1589 | (deftest sbcl.54 |
---|
1590 | (check-readable-or-signals-error (parse-namestring "SCRATCH:FOO.TXT")) |
---|
1591 | t) |
---|
1592 | |
---|
1593 | (deftest sbcl.55 |
---|
1594 | (equal (parse-namestring "foo" nil "/") |
---|
1595 | (parse-namestring "foo" nil #p"/")) |
---|
1596 | t) |
---|
1597 | |
---|
1598 | #-allegro |
---|
1599 | (deftest sbcl.56 |
---|
1600 | (let ((test "parse-namestring-test.tmp")) |
---|
1601 | (unwind-protect |
---|
1602 | (with-open-file (f test :direction :output) |
---|
1603 | ;; FIXME: This test is a bit flaky, since we only check that |
---|
1604 | ;; no error is signalled. The dilemma here is "what is the |
---|
1605 | ;; correct result when defaults is a _file_, not a |
---|
1606 | ;; directory". Currently (0.8.10.73) we get #P"foo" here (as |
---|
1607 | ;; opposed to eg. #P"/path/to/current/foo"), which is |
---|
1608 | ;; possibly mildly surprising but probably conformant. |
---|
1609 | (equal (parse-namestring "foo" nil f) #p"foo")) |
---|
1610 | (when (probe-file test) |
---|
1611 | (delete-file test)))) |
---|
1612 | t) |
---|
1613 | |
---|
1614 | ;;; ENOUGH-NAMESTRING should probably not fail when the namestring in |
---|
1615 | ;;; question has a :RELATIVE pathname. |
---|
1616 | (deftest sbcl.57 |
---|
1617 | (equal (enough-namestring #p"foo" #p"./") "foo") |
---|
1618 | t) |
---|
1619 | |
---|
1620 | ;;; bug reported by Artem V. Andreev: :WILD not handled in unparsing |
---|
1621 | ;;; directory lists. |
---|
1622 | (deftest sbcl.58 |
---|
1623 | (check-namestring #p"/tmp/*/" "/tmp/*/") |
---|
1624 | t) |
---|
1625 | |
---|
1626 | #-allegro |
---|
1627 | (deftest sbcl.59 |
---|
1628 | (string= (with-standard-io-syntax (write-to-string #p"/foo")) |
---|
1629 | #-windows "#P\"/foo\"" |
---|
1630 | #+(and windows (not lispworks)) "#P\"\\\\foo\"" |
---|
1631 | #+(and windows lispworks) "#P\"/foo\"") |
---|
1632 | t) |
---|
1633 | |
---|
1634 | #-allegro |
---|
1635 | (deftest sbcl.60 |
---|
1636 | (string= (with-standard-io-syntax (write-to-string #p"/foo" :readably nil)) |
---|
1637 | #-windows "#P\"/foo\"" |
---|
1638 | #+(and windows (not lispworks)) "#P\"\\\\foo\"" |
---|
1639 | #+(and windows lispworks) "#P\"/foo\"") |
---|
1640 | t) |
---|
1641 | |
---|
1642 | #-allegro |
---|
1643 | (deftest sbcl.61 |
---|
1644 | (string= (with-standard-io-syntax (write-to-string #p"/foo" :escape nil)) |
---|
1645 | #-windows "#P\"/foo\"" |
---|
1646 | #+(and windows (not lispworks)) "#P\"\\\\foo\"" |
---|
1647 | #+(and windows lispworks) "#P\"/foo\"") |
---|
1648 | t) |
---|
1649 | |
---|
1650 | (deftest sbcl.62 |
---|
1651 | (string= (with-standard-io-syntax (write-to-string #p"/foo" :readably nil :escape nil)) |
---|
1652 | #-windows "/foo" |
---|
1653 | #+windows "\\foo") |
---|
1654 | t) |
---|