Tests for the implementation of URI encoding. diff --git a/abcl.asd b/abcl.asd --- a/abcl.asd +++ b/abcl.asd @@ -47,7 +47,7 @@ (:file "file-system-tests") #+abcl (:file "jar-pathname" :depends-on - ("pathname-tests")) + ("pathname-tests" "file-system-tests")) #+abcl (:file "url-pathname") (:file "math-tests") diff --git a/test/lisp/abcl/jar-pathname.lisp b/test/lisp/abcl/jar-pathname.lisp --- a/test/lisp/abcl/jar-pathname.lisp +++ b/test/lisp/abcl/jar-pathname.lisp @@ -33,6 +33,12 @@ (cl-fad-copy-stream in out)))) (values)) +(defvar *foo.lisp* + `(defun foo () + (labels ((output () + (format t "FOO here."))) + (output)))) + (defun jar-file-init () (let* ((*default-pathname-defaults* *abcl-test-directory*) (asdf::*verbose-out* *standard-output*)) @@ -129,6 +135,35 @@ (load "jar:file:baz.jar!/d/e+f/bar.abcl")) t) +(defmacro with-temp-directory ((directory) &rest body) + `(let ((*default-pathname-defaults* *abcl-test-directory*)) + (ensure-directories-exist ,directory) + (prog1 + ,@body + (delete-directory-and-files ,directory)))) + +;;; Not really a JAR-PATHNAME test +(deftest jar-pathname.load.12 + (let ((dir (merge-pathnames "dir+with+plus/" + *abcl-test-directory*))) + (with-temp-directory (dir) + (let ((file (merge-pathnames "foo.lisp" dir))) + (with-open-file (s file :direction :output) + (write *foo.lisp* :stream s)) + (load file)))) + t) + +;;; Not really a JAR-PATHNAME test +(deftest jar-pathname.load.12 + (let ((dir (merge-pathnames "dir with space/" + *abcl-test-directory*))) + (with-temp-directory (dir) + (let ((file (merge-pathnames "foo.lisp" dir))) + (with-open-file (s file :direction :output) + (write *foo.lisp* :stream s)) + (load file)))) + t) + ;;; wrapped in PROGN for easy disabling without a network connection ;;; XXX come up with a better abstraction @@ -341,19 +376,28 @@ (:relative "a" "b") "foo" "jar" (:absolute "c" "d") "foo" "lisp") +;;; 'jar:file:' forms must be URI encoded, meaning whitespace is not allowed (deftest jar-pathname.10 - (let ((s "jar:file:/foo/bar/a space/that!/this")) - (equal s + (signals-error + (let ((s "jar:file:/foo/bar/a space/that!/this")) + (equal s + (namestring (pathname s)))) + 'file-error) + t) + +(deftest jar-pathname.11 + (let ((s "jar:file:/foo/bar/a%20space%3f/that!/this")) + (string= s (namestring (pathname s)))) t) -(deftest jar-pathname.11 - (let ((s "jar:file:/foo/bar/a+space/that!/this")) - (equal s - (namestring (pathname s)))) +;;; We allow jar-pathname to be contructed without a device to allow +;;; MERGE-PATHNAMES to work, even though #p"file:" is illegal. +(deftest jar-pathname.12 + (string= (namestring (first (pathname-device #p"jar:file:!/foo.bar"))) + "") t) - (deftest jar-pathname.match-p.1 (pathname-match-p "jar:file:/a/b/some.jar!/a/system/def.asd" "jar:file:/**/*.jar!/**/*.asd") diff --git a/test/lisp/abcl/pathname-tests.lisp b/test/lisp/abcl/pathname-tests.lisp --- a/test/lisp/abcl/pathname-tests.lisp +++ b/test/lisp/abcl/pathname-tests.lisp @@ -1681,3 +1681,15 @@ (type-error () t)) t) +(deftest pathname.uri-encoding.1 + (signals-error + (let ((s "file:/path with /spaces")) + (equal s + (namestring (pathname s)))) + 'file-error) + t) + +(deftest pathname.uri-encoding.2 + (equal "/path with/funny/?characters/" + (namestring (pathname "file:/path%20with/funny/%3fcharacters/"))) + t)