Changeset 13326


Ignore:
Timestamp:
06/10/11 15:53:12 (12 years ago)
Author:
Mark Evenson
Message:

Add tests for whitespace in pathname.

Refactor jar-pathname tests via LOAD-JAR-RELATIVE macro.

Use DEFPARAMETER rather than DEFVAR.

Add paths containing whitespace to local jar in preparation for
expanding the test suite to more failing cases.

*TMP-JAR_PATH* now contains the path to jar used for testing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/test/lisp/abcl/jar-pathname.lisp

    r13324 r13326  
    11(in-package #:abcl.test.lisp)
    22
    3 (defvar *jar-file-init* nil)
    4 
    53(defparameter *tmp-directory* nil)
     4(defparameter *tmp-directory-whitespace* nil)
     5(defparameter *tmp-jar-path* nil)
     6(defparameter *tmp-jar-path-whitespace* nil)
    67
    78(eval-when (:compile-toplevel :load-toplevel)
     
    1213                                   (append
    1314                                    (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*))))
    1518
    1619(defvar *foo.lisp*
     
    5760    (write-forms *foo.lisp* "foo.lisp")
    5861    (compile-file "foo.lisp")
     62    (write-forms *foo.lisp* "foo bar.lisp")
     63    (compile-file "foo bar.lisp")
    5964    (write-forms *bar.lisp* "bar.lisp")
    6065    (compile-file "bar.lisp")
     
    6469           (subdirs
    6570            (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/")))
    6772           (sub1 (first subdirs))
    68            (sub2 (second subdirs)))
     73           (sub2 (second subdirs))
     74           (sub3 (third subdirs)))
    6975      (when (probe-directory tmpdir)
    7076        (delete-directory-and-files tmpdir))
     
    7278      (sys:unzip (merge-pathnames "foo.abcl") tmpdir)
    7379      (sys:unzip (merge-pathnames "foo.abcl") sub1)
     80      (sys:unzip (merge-pathnames "foo.abcl") sub3)
     81      (sys:unzip (merge-pathnames "foo bar.abcl") sub3)
    7482      (cl-fad-copy-file (merge-pathnames "bar.abcl")
    7583                        (merge-pathnames "bar.abcl" tmpdir))
    7684      (cl-fad-copy-file (merge-pathnames "bar.abcl")
    7785                        (merge-pathnames "bar.abcl" sub1))
     86      (cl-fad-copy-file (merge-pathnames "foo bar.abcl")
     87                        (merge-pathnames "foo bar.abcl" sub1))
    7888      (cl-fad-copy-file (merge-pathnames "bar.abcl")
    7989                        (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))
    8094      (cl-fad-copy-file (merge-pathnames "eek.lisp")
    8195                        (merge-pathnames "eek.lisp" tmpdir))
    8296      (cl-fad-copy-file (merge-pathnames "eek.lisp")
    8397                        (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*)))
    90111
    91112(defmacro with-jar-file-init (&rest body)
    92113  `(let ((*default-pathname-defaults* *tmp-directory*))
    93114     (progn
    94        (unless *jar-file-init*
     115       (unless (and *tmp-jar-path* (probe-file *tmp-jar-path*))
    95116         (jar-file-init))
    96117       ,@body)))
    97118
     119(defmacro load-from-jar (jar path)
     120  `(with-jar-file-init
     121       (load (format nil "jar:file:~A!/~A" ,jar ,path))))
     122
    98123(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")
    101125  t)
    102126
    103127(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")
    106129  t)
    107130
    108131(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")
    111133  t)
    112134
    113135(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")
    116137  t)
    117138
    118139(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")
    121141  t)
    122142
    123143(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")
    126145  t)
    127146
    128147(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")
    131149  t)
    132150
    133151(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")
    136153  t)
    137154
    138155(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")
    141157  t)
    142158
    143159(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")
    146161  t)
    147162
    148163(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)))
    152192
    153193;;; wrapped in PROGN for easy disabling without a network connection
    154194;;; 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)))
    161195
    162196(progn
Note: See TracChangeset for help on using the changeset viewer.