Changeset 13326
- Timestamp:
- 06/10/11 15:53:12 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/test/lisp/abcl/jar-pathname.lisp
r13324 r13326 1 1 (in-package #:abcl.test.lisp) 2 2 3 (defvar *jar-file-init* nil)4 5 3 (defparameter *tmp-directory* nil) 4 (defparameter *tmp-directory-whitespace* nil) 5 (defparameter *tmp-jar-path* nil) 6 (defparameter *tmp-jar-path-whitespace* nil) 6 7 7 8 (eval-when (:compile-toplevel :load-toplevel) … … 12 13 (append 13 14 (pathname-directory (pathname temp-file)) 14 '("jar-pathname-tests"))))))) 15 '("jar-pathname-tests")))) 16 *tmp-directory-whitespace* 17 (merge-pathnames "a/directory with/s p a/" *tmp-directory*)))) 15 18 16 19 (defvar *foo.lisp* … … 57 60 (write-forms *foo.lisp* "foo.lisp") 58 61 (compile-file "foo.lisp") 62 (write-forms *foo.lisp* "foo bar.lisp") 63 (compile-file "foo bar.lisp") 59 64 (write-forms *bar.lisp* "bar.lisp") 60 65 (compile-file "bar.lisp") … … 64 69 (subdirs 65 70 (mapcar (lambda (p) (merge-pathnames p tmpdir)) 66 '("a/b/" "d/e+f/" )))71 '("a/b/" "d/e+f/" "path/with a couple/spaces/in it/"))) 67 72 (sub1 (first subdirs)) 68 (sub2 (second subdirs))) 73 (sub2 (second subdirs)) 74 (sub3 (third subdirs))) 69 75 (when (probe-directory tmpdir) 70 76 (delete-directory-and-files tmpdir)) … … 72 78 (sys:unzip (merge-pathnames "foo.abcl") tmpdir) 73 79 (sys:unzip (merge-pathnames "foo.abcl") sub1) 80 (sys:unzip (merge-pathnames "foo.abcl") sub3) 81 (sys:unzip (merge-pathnames "foo bar.abcl") sub3) 74 82 (cl-fad-copy-file (merge-pathnames "bar.abcl") 75 83 (merge-pathnames "bar.abcl" tmpdir)) 76 84 (cl-fad-copy-file (merge-pathnames "bar.abcl") 77 85 (merge-pathnames "bar.abcl" sub1)) 86 (cl-fad-copy-file (merge-pathnames "foo bar.abcl") 87 (merge-pathnames "foo bar.abcl" sub1)) 78 88 (cl-fad-copy-file (merge-pathnames "bar.abcl") 79 89 (merge-pathnames "bar.abcl" sub2)) 90 (cl-fad-copy-file (merge-pathnames "bar.abcl") 91 (merge-pathnames "bar.abcl" sub3)) 92 (cl-fad-copy-file (merge-pathnames "foo bar.abcl") 93 (merge-pathnames "foo bar.abcl" sub3)) 80 94 (cl-fad-copy-file (merge-pathnames "eek.lisp") 81 95 (merge-pathnames "eek.lisp" tmpdir)) 82 96 (cl-fad-copy-file (merge-pathnames "eek.lisp") 83 97 (merge-pathnames "eek.lisp" sub1)) 84 (sys:zip (merge-pathnames "baz.jar") 85 (loop :for p :in (list tmpdir sub1 sub2) 86 :appending (directory (merge-pathnames "*" p))) 87 tmpdir) 88 #+nil (delete-directory-and-files dir))) 89 (setf *jar-file-init* t)) 98 (setf *tmp-jar-path* 99 (sys:zip (merge-pathnames "baz.jar") 100 (loop :for p :in (list tmpdir sub1 sub2 sub3) 101 :appending (directory (merge-pathnames "*" p))) 102 tmpdir)) 103 (ensure-directories-exist *tmp-directory-whitespace*) 104 (setf *tmp-jar-path-whitespace* 105 (merge-pathnames "baz.jar" *tmp-directory-whitespace*)) 106 (cl-fad-copy-file *tmp-jar-path* *tmp-jar-path-whitespace*)))) 107 108 (defun clean-jar-tests () 109 (when (probe-file *tmp-directory*) 110 (delete-directory-and-files *tmp-directory*))) 90 111 91 112 (defmacro with-jar-file-init (&rest body) 92 113 `(let ((*default-pathname-defaults* *tmp-directory*)) 93 114 (progn 94 (unless *jar-file-init*115 (unless (and *tmp-jar-path* (probe-file *tmp-jar-path*)) 95 116 (jar-file-init)) 96 117 ,@body))) 97 118 119 (defmacro load-from-jar (jar path) 120 `(with-jar-file-init 121 (load (format nil "jar:file:~A!/~A" ,jar ,path)))) 122 98 123 (deftest jar-pathname.load.1 99 (with-jar-file-init 100 (load "jar:file:baz.jar!/foo")) 124 (load-from-jar *tmp-jar-path* "foo") 101 125 t) 102 126 103 127 (deftest jar-pathname.load.2 104 (with-jar-file-init 105 (load "jar:file:baz.jar!/bar")) 128 (load-from-jar *tmp-jar-path* "bar") 106 129 t) 107 130 108 131 (deftest jar-pathname.load.3 109 (with-jar-file-init 110 (load "jar:file:baz.jar!/bar.abcl")) 132 (load-from-jar *tmp-jar-path* "bar.abcl") 111 133 t) 112 134 113 135 (deftest jar-pathname.load.4 114 (with-jar-file-init 115 (load "jar:file:baz.jar!/eek")) 136 (load-from-jar *tmp-jar-path* "eek") 116 137 t) 117 138 118 139 (deftest jar-pathname.load.5 119 (with-jar-file-init 120 (load "jar:file:baz.jar!/eek.lisp")) 140 (load-from-jar *tmp-jar-path* "eek.lisp") 121 141 t) 122 142 123 143 (deftest jar-pathname.load.6 124 (with-jar-file-init 125 (load "jar:file:baz.jar!/a/b/foo")) 144 (load-from-jar *tmp-jar-path* "foo") 126 145 t) 127 146 128 147 (deftest jar-pathname.load.7 129 (with-jar-file-init 130 (load "jar:file:baz.jar!/a/b/bar")) 148 (load-from-jar *tmp-jar-path* "a/b/bar") 131 149 t) 132 150 133 151 (deftest jar-pathname.load.8 134 (with-jar-file-init 135 (load "jar:file:baz.jar!/a/b/bar.abcl")) 152 (load-from-jar *tmp-jar-path* "a/b/bar.abcl") 136 153 t) 137 154 138 155 (deftest jar-pathname.load.9 139 (with-jar-file-init 140 (load "jar:file:baz.jar!/a/b/eek")) 156 (load-from-jar *tmp-jar-path* "a/b/eek") 141 157 t) 142 158 143 159 (deftest jar-pathname.load.10 144 (with-jar-file-init 145 (load "jar:file:baz.jar!/a/b/eek.lisp")) 160 (load-from-jar *tmp-jar-path* "a/b/eek.lisp") 146 161 t) 147 162 148 163 (deftest jar-pathname.load.11 149 (with-jar-file-init 150 (load "jar:file:baz.jar!/d/e+f/bar.abcl")) 151 t) 164 (load-from-jar *tmp-jar-path* "d/e+f/bar.abcl") 165 t) 166 167 (deftest jar-pathname.load.12 168 (load-from-jar *tmp-jar-path* "a/b/foo%20bar.abcl") 169 t) 170 171 (deftest jar-pathname.load.13 172 (load-from-jar *tmp-jar-path* "a/b/foo bar.abcl") 173 t) 174 175 (deftest jar-pathname.load.14 176 (load-from-jar *tmp-jar-path-whitespace* "a/b/foo.abcl") 177 t) 178 179 (deftest jar-pathname.load.15 180 (load-from-jar *tmp-jar-path-whitespace* "a/b/foo bar.abcl") 181 t) 182 183 (deftest jar-pathname.load.16 184 (load-from-jar *tmp-jar-path-whitespace* "a/b/foo%20bar.abcl") 185 t) 186 187 (defparameter *url-jar-pathname-base* 188 "jar:http://abcl-dynamic-install.googlecode.com/files/baz-20110610a.jar!/") 189 190 (defmacro load-url-relative (path) 191 `(load (format nil "~A~A" *url-jar-pathname-base* ,path))) 152 192 153 193 ;;; wrapped in PROGN for easy disabling without a network connection 154 194 ;;; XXX come up with a better abstraction 155 156 (defvar *url-jar-pathname-base*157 "jar:http://abcl-dynamic-install.googlecode.com/files/baz-20110610a.jar!/")158 159 (defmacro load-url-relative (path)160 `(load (format nil "~A~A" *url-jar-pathname-base* ,path)))161 195 162 196 (progn
Note: See TracChangeset
for help on using the changeset viewer.