X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fpathnames.impure.lisp;h=d462c1be4c3e47e0a065645ff14127b8016eb5a2;hb=3924eb24605ed3ff0951155d271a7fea15656e7d;hp=4afbba068fe602d06f40b2f16e2525202ed61ce0;hpb=4fc9d21ae1d8a6a2f8ff70f589d5da103203de13;p=sbcl.git diff --git a/tests/pathnames.impure.lisp b/tests/pathnames.impure.lisp index 4afbba0..d462c1b 100644 --- a/tests/pathnames.impure.lisp +++ b/tests/pathnames.impure.lisp @@ -16,9 +16,7 @@ (in-package "CL-USER") -(defmacro grab-condition (&body body) - `(nth-value 1 - (ignore-errors ,@body))) +(load "assertoid.lisp") (setf (logical-pathname-translations "demo0") '(("**;*.*.*" "/tmp/"))) @@ -75,6 +73,25 @@ (assert (equal pn1 pn2)) (assert (equal pn1 pn3))) +;;; In addition to the upper-case constraint above, if the logical-pathname +;;; contains a string component in e.g. the directory, name and type slot, +;;; these should be valid "WORDS", according to CLHS 19.3.1. +;;; FIXME: currently SBCL throws NAMESTRING-PARSE-ERROR: should this be +;;; a TYPE-ERROR? + +;; error: directory-component not valid +(assert (not (ignore-errors + (make-pathname :host "FOO" :directory "!bla" :name "bar")))) + +;; error: name-component not valid +(assert (not (ignore-errors + (make-pathname :host "FOO" :directory "bla" :name "!bar")))) + +;; error: type-component not valid. +(assert (not (ignore-errors + (make-pathname :host "FOO" :directory "bla" :name "bar" + :type "&baz")))) + ;;; We may need to parse the host as a LOGICAL-NAMESTRING HOST. The ;;; HOST in PARSE-NAMESTRING can be either a string or :UNSPECIFIC ;;; without actually requiring the system to signal an error (apart @@ -93,6 +110,12 @@ (let ((cond (grab-condition (parse-namestring "foo:jeamland" "demo2")))) (assert (typep cond 'type-error))) +;;; turning one logical pathname into another: +(setf (logical-pathname-translations "foo") + '(("tohome;*.*.*" "home:*.*.*"))) +(assert (equal (namestring (translate-logical-pathname "foo:tohome;x.y")) + "home:x.y")) + ;;; ANSI, in its wisdom, specifies that it's an error (specifically a ;;; TYPE-ERROR) to query the system about the translations of a string ;;; which doesn't have any translations. It's not clear why we don't @@ -100,13 +123,18 @@ (let ((cond (grab-condition (logical-pathname-translations "unregistered-host")))) (assert (typep cond 'type-error))) -;;; examples from CLHS: Section 19.4, Logical Pathname Translations -;;; (sometimes converted to the Un*x way of things) +;;; FIXME: A comment on this section up to sbcl-0.6.11.30 or so said +;;; examples from CLHS: Section 19.4, LOGICAL-PATHNAME-TRANSLATIONS +;;; (sometimes converted to the Un*x way of things) +;;; but when I looked it up I didn't see the connection. Presumably +;;; there's some code in this section which should be attributed +;;; to something in the ANSI spec, but I don't know what code it is +;;; or what section of the specification has the related code. (setf (logical-pathname-translations "test0") '(("**;*.*.*" "/library/foo/**/"))) (assert (equal (namestring (translate-logical-pathname - "test0:foo;bar;baz;mum.quux.3")) - "/library/foo/foo/bar/baz/mum.quux.3")) + "test0:foo;bar;baz;mum.quux")) + "/library/foo/foo/bar/baz/mum.quux")) (setf (logical-pathname-translations "prog") '(("RELEASED;*.*.*" "MY-UNIX:/sys/bin/my-prog/") ("RELEASED;*;*.*.*" "MY-UNIX:/sys/bin/my-prog/*/") @@ -124,5 +152,12 @@ "prog:code;documentation.lisp")) "/lib/prog/docum.lisp")) +;;; ANSI section 19.3.1.1.5 specifies that translation to a filesystem +;;; which doesn't have versions should ignore the version slot. CMU CL +;;; didn't ignore this as it should, but we do. +(assert (equal (namestring (translate-logical-pathname + "test0:foo;bar;baz;mum.quux.3")) + "/library/foo/foo/bar/baz/mum.quux")) + ;;; success (quit :unix-status 104)