source: trunk/abcl/test/lisp/abcl/jar-file.lisp @ 12402

Last change on this file since 12402 was 12402, checked in by Mark Evenson, 12 years ago

Move abcl-test-lisp to ASDF packaging.

Change to ASDF packaging of abcl-test-lisp. Remove ASDF system
'abcl-tests' as ASDF systems without components don't carry
dependencies transitively. Remove unneed :BEFORE load of
abcl-test-lisp. Renamed conflicting tests now that they are loaded via
ASDF.

Implement ability to run tests matching a string. Export
ABCL.TEST.LISP::RUN-MATCHING as external symbol.

Added 'test/lisp/abcl/math-tests.lisp' back to ABCL.TEST.LISP, fixing
errors that prevented it from working.

Fix bug with directories specified to three-arg form of SYS:ZIP. JAR
files always use '/' to name hierarchial entries. Allow of a top
directory for creating hierarchially ZIPs: for arguments like
"pathname pathnames &optional topdir" all pathnames will be
interpolated relative to topdir.

Contains the version of jar-file tests corresponding to PATHNAME,
TRUENAME, and PROBE-FILE. The tests for jar-file will currently fail
as it needs the implementation of SYS:UNZIP which in turn depends on
the new version of Pathname which should follow shortly in a separate
commit.

jar-file initilization rewritten in Lisp, so it works under Windows.

Java tests for Pathname and Stream.

Help my dyslexic brain by renaming
*abcl-{lisp-test,test,lisp}-directory* to *abcl-test-directory*.

Refinement of jar-file tests. Correct all JAR-FILE.PATHNAME.* tests.
JAR-FILE tests use the cross-platform form of COPY-FILE. Renamed test,
using WITH-JAR-FILE-INIT macro.

File size: 8.6 KB
Line 
1(in-package #:abcl.test.lisp)
2
3(defvar *jar-file-init* nil)
4
5;;; From CL-FAD
6(defvar *stream-buffer-size* 8192)
7(defun cl-fad-copy-stream (from to &optional (checkp t))
8  "Copies into TO \(a stream) from FROM \(also a stream) until the end
9of FROM is reached, in blocks of *stream-buffer-size*.  The streams
10should have the same element type.  If CHECKP is true, the streams are
11checked for compatibility of their types."
12  (when checkp
13    (unless (subtypep (stream-element-type to) (stream-element-type from))
14      (error "Incompatible streams ~A and ~A." from to)))
15  (let ((buf (make-array *stream-buffer-size*
16                         :element-type (stream-element-type from))))
17    (loop
18     (let ((pos (read-sequence buf from)))
19       (when (zerop pos) (return))
20       (write-sequence buf to :end pos))))
21  (values))
22
23(defun cl-fad-copy-file (from to &key overwrite)
24  "Copies the file designated by the non-wild pathname designator FROM
25to the file designated by the non-wild pathname designator TO.  If
26OVERWRITE is true overwrites the file designtated by TO if it exists."
27  (let ((element-type '(unsigned-byte 8)))
28    (with-open-file (in from :element-type element-type)
29      (with-open-file (out to :element-type element-type
30                              :direction :output
31                              :if-exists (if overwrite
32                                           :supersede :error))
33        (cl-fad-copy-stream in out))))
34  (values))
35
36(defun jar-file-init ()
37  (let* ((*default-pathname-defaults*  *abcl-test-directory*)
38         (asdf::*verbose-out* *standard-output*))
39    (compile-file "foo.lisp")
40    (compile-file "bar.lisp")
41    (compile-file "eek.lisp")
42    (let* ((dir (merge-pathnames "tmp/" *abcl-test-directory*))
43           (sub (merge-pathnames "a/b/" dir)))
44      (when (probe-directory dir)
45        (delete-directory-and-files dir))
46      (ensure-directories-exist sub)
47      (sys:unzip (merge-pathnames "foo.abcl")
48                 dir)
49      (sys:unzip (merge-pathnames "foo.abcl")
50                 sub)
51      (cl-fad-copy-file (merge-pathnames "bar.abcl")
52                 (merge-pathnames "bar.abcl" dir))
53      (cl-fad-copy-file (merge-pathnames "bar.abcl")
54                 (merge-pathnames "bar.abcl" sub))
55      (cl-fad-copy-file (merge-pathnames "eek.lisp")
56                 (merge-pathnames "eek.lisp" dir))
57      (cl-fad-copy-file (merge-pathnames "eek.lisp")
58                 (merge-pathnames "eek.lisp" sub))
59      (sys:zip (merge-pathnames "baz.jar")
60               (append
61                (directory (merge-pathnames "*" dir))
62                (directory (merge-pathnames "*" sub)))
63               dir)
64      (delete-directory-and-files dir)))
65  (setf *jar-file-init* t))
66
67(defmacro with-jar-file-init (&rest body)
68  `(let ((*default-pathname-defaults* *abcl-test-directory*))
69     (progn
70       (unless *jar-file-init*
71         (jar-file-init))
72       ,@body)))
73
74#+nil
75(defmacro with-jar-file-init (&rest body)
76  `(progv '(*default-pathname-defaults*) '(,*abcl-test-directory*)
77    (unless *jar-file-init*
78      (load-init))
79    ,@body))
80
81(deftest jar-file.load.1
82    (with-jar-file-init
83      (load "jar:file:baz.jar!/foo"))
84  t)
85
86(deftest jar-file.load.2
87    (with-jar-file-init
88      (load "jar:file:baz.jar!/bar"))
89  t)
90
91(deftest jar-file.load.3
92    (with-jar-file-init
93      (load "jar:file:baz.jar!/bar.abcl"))
94  t)
95
96(deftest jar-file.load.4
97    (with-jar-file-init
98      (load "jar:file:baz.jar!/eek"))
99  t)
100
101(deftest jar-file.load.5
102    (with-jar-file-init
103      (load "jar:file:baz.jar!/eek.lisp"))
104  t)
105
106(deftest jar-file.load.6
107    (with-jar-file-init
108      (load "jar:file:baz.jar!/a/b/foo"))
109  t)
110
111(deftest jar-file.load.7
112    (with-jar-file-init
113      (load "jar:file:baz.jar!/a/b/bar"))
114  t)
115
116(deftest jar-file.load.8
117    (with-jar-file-init
118      (load "jar:file:baz.jar!/a/b/bar.abcl"))
119  t)
120
121(deftest jar-file.load.9
122    (with-jar-file-init
123      (load "jar:file:baz.jar!/a/b/eek"))
124  t)
125
126(deftest jar-file.load.10
127    (with-jar-file-init
128      (load "jar:file:baz.jar!/a/b/eek.lisp"))
129  t)
130
131(deftest jar-file.probe-file.1
132    (with-jar-file-init
133        (probe-file "jar:file:baz.jar!/eek.lisp"))
134  #p#.(format nil "jar:file:~A/baz.jar!/eek.lisp" 
135              (namestring *abcl-test-directory*)))
136
137(deftest jar-file.probe-file.2
138    (with-jar-file-init
139        (probe-file "jar:file:baz.jar!/a/b/bar.abcl"))
140  #p#.(format nil "jar:file:~A/baz.jar!/a/b/bar.abcl"
141              (namestring *abcl-test-directory*)))
142
143(deftest jar-file.probe-file.3
144    (with-jar-file-init
145        (probe-file "jar:jar:file:baz.jar!/a/b/bar.abcl!/bar._"))
146   #p#.(format nil "jar:jar:file:~Abaz.jar!/a/b/bar.abcl!/bar._"
147                       (namestring *abcl-test-directory*)))
148
149(deftest jar-file.probe-file.4
150    (with-jar-file-init
151        (probe-file "jar:file:baz.jar!/a/b"))
152  nil)
153
154(deftest jar-file.probe-file.5
155    (with-jar-file-init
156        (probe-file "jar:file:baz.jar!/a/b/"))
157  #p#.(format nil "jar:file:~Abaz.jar!/a/b/"
158                       (namestring *abcl-test-directory*)))
159
160(deftest jar-file.merge-pathnames.1
161    (merge-pathnames 
162     "/bar.abcl" #p"jar:file:baz.jar!/foo")
163  #p"jar:file:baz.jar!/bar.abcl")
164
165(deftest jar-file.merge-pathnames.2
166    (merge-pathnames 
167     "/bar.abcl" #p"jar:file:baz.jar!/foo/")
168  #p"jar:file:baz.jar!/foo/bar.abcl")
169
170(deftest jar-file.merge-pathnames.3
171    (merge-pathnames 
172     "jar:file:baz.jar!/foo" "bar")
173  #p"jar:file:baz.jar!/foo")
174
175(deftest jar-file.truename.1
176    (signals-error (truename "jar:file:baz.jar!/foo")
177                   'file-error)
178  t)
179
180
181(deftest jar-file.pathname.1
182    (let* ((p #p"jar:file:foo/baz.jar!/")
183           (d (first (pathname-device p))))
184      (values
185       (pathname-directory d) (pathname-name d) (pathname-type d)))
186  (:relative "foo") "baz" "jar")
187
188(deftest jar-file.pathname.2
189    (let* ((p #p"jar:file:baz.jar!/foo.abcl")
190           (d (first (pathname-device p))))
191      (values
192       (pathname-name d) (pathname-type d) 
193       (pathname-directory p) (pathname-name p) (pathname-type p)))
194  "baz" "jar"
195   nil "foo" "abcl")
196   
197(deftest jar-file.pathname.3
198    (let* ((p #p"jar:jar:file:baz.jar!/foo.abcl!/")
199           (d0 (first (pathname-device p)))
200           (d1 (second (pathname-device p))))
201      (values 
202       (pathname-name d0) (pathname-type d0)
203       (pathname-name d1) (pathname-type d1)))
204  "baz" "jar"
205  "foo" "abcl")
206
207(deftest jar-file.pathname.4
208    (let* ((p #p"jar:jar:file:a/baz.jar!/b/c/foo.abcl!/this/that/foo-20.cls")
209           (d0 (first (pathname-device p)))
210           (d1 (second (pathname-device p))))
211      (values 
212       (pathname-directory d0) (pathname-name d0) (pathname-type d0)
213       (pathname-directory d1) (pathname-name d1) (pathname-type d1)
214       (pathname-directory p) (pathname-name p) (pathname-type p)))
215  (:relative "a") "baz" "jar"
216  (:relative "b" "c") "foo" "abcl"
217  (:relative "this" "that") "foo-20" "cls")
218
219(deftest jar-file.pathname.5
220    (let* ((p #p"jar:jar:file:a/foo/baz.jar!/b/c/foo.abcl!/armed/bear/bar-1.cls")
221           (d0 (first (pathname-device p)))
222           (d1 (second (pathname-device p))))
223      (values 
224       (pathname-directory d0) (pathname-name d0) (pathname-type d0)
225       (pathname-directory d1) (pathname-name d1) (pathname-type d1)
226       (pathname-directory p) (pathname-name p) (pathname-type p)))
227  (:relative "a" "foo" ) "baz" "jar"
228  (:relative "b" "c") "foo" "abcl"
229  (:relative "armed" "bear") "bar-1" "cls")
230
231(deftest jar-file.pathname.6
232    (let* ((p #p"jar:http://example.org/abcl.jar!/org/armedbear/lisp/Version.class")
233           (d (first (pathname-device p))))
234
235      (values 
236       d
237       (pathname-directory p) (pathname-name p) (pathname-type p)))
238  "http://example.org/abcl.jar" 
239  (:relative "org" "armedbear" "lisp") "Version" "class")
240
241(deftest jar-file.pathname.7
242    (let* ((p #p"jar:jar:http://example.org/abcl.jar!/foo.abcl!/foo-1.cls")
243           (d (pathname-device p))
244           (d0 (first d))
245           (d1 (second d)))
246      (values
247       d0 
248       (pathname-name d1) (pathname-type d1)
249       (pathname-name p) (pathname-type p)))
250  "http://example.org/abcl.jar"
251  "foo" "abcl"
252  "foo-1" "cls")
253
254(deftest jar-file.pathname.8
255    (let* ((p #p"jar:file:/a/b/foo.jar!/")
256           (d (first (pathname-device p))))
257      (values
258       (pathname-directory d) (pathname-name d) (pathname-type d)))
259  (:ABSOLUTE "a" "b") "foo" "jar")
260
261(deftest jar-file.pathname.9
262    (let* ((p #p"jar:file:a/b/foo.jar!/c/d/foo.lisp")
263           (d (first (pathname-device p))))
264      (values
265       (pathname-directory d) (pathname-name d) (pathname-type d)
266       (pathname-directory p) (pathname-name p) (pathname-type p)))
267  (:RELATIVE "a" "b") "foo" "jar"
268  (:RELATIVE "c" "d") "foo" "lisp")
269
270     
271     
272             
273
274       
275       
276
277 
Note: See TracBrowser for help on using the repository browser.