Ignore:
Timestamp:
08/11/11 15:21:45 (10 years ago)
Author:
Mark Evenson
Message:

Fix JAR-PATHNAME tests.

Remove the wrong-headed use of TRUENAME at compile time which would
error unless the test directory had previously been created.

Remove the use of the readtime #. macro to create the success
conditions for tests which were failing based on the presence of the
temporary jar directory.

These bugs seem show the need for a more explicit test
build-up/tear-down sequence as the complexity in manage Lisp macros
here leads to a lot of unncessary bugs.

File:
1 edited

Legend:

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

    r13353 r13457  
    55(defparameter *tmp-jar-path* nil)
    66(defparameter *tmp-jar-path-whitespace* nil)
    7 
    8 (eval-when (:compile-toplevel :load-toplevel)
    9   (let ((temp-file (java:jcall "getAbsolutePath"
    10                                (java:jstatic "createTempFile" "java.io.File" "jar" "tmp"))))
    11     (setf *tmp-directory*
    12           (truename (make-pathname :directory
    13                                    (append
    14                                     (pathname-directory (pathname temp-file))
    15                                     '("jar-pathname-tests"))))
    16           *tmp-directory-whitespace*
    17           (merge-pathnames "a/directory with/s p a/" *tmp-directory*))))
    187
    198(defvar *foo.lisp*
     
    5443
    5544(defun jar-file-init ()
     45  (let* ((temp-file (java:jcall "getAbsolutePath"
     46                               (java:jstatic "createTempFile" "java.io.File" "jar" "tmp")))
     47         (temp-dir (make-pathname :directory (append
     48                                              (pathname-directory (pathname temp-file))
     49                                              '("jar-pathname-tests")))))
     50    (ensure-directories-exist temp-dir)
     51    (setf *tmp-directory*
     52          (truename temp-dir)
     53          *tmp-directory-whitespace*
     54          (merge-pathnames "a/directory with/s p a/" *tmp-directory*)))
    5655  (format t "~&Using ~A to create files for testing jar-pathnames.~%" *tmp-directory*)
    5756  (ensure-directories-exist *tmp-directory*)
     
    111110
    112111(defmacro with-jar-file-init (&rest body)
    113   `(let ((*default-pathname-defaults* *tmp-directory*))
    114      (progn
    115        (unless (and *tmp-jar-path* (probe-file *tmp-jar-path*))
    116          (jar-file-init))
     112  `(progn
     113     (unless (and *tmp-jar-path* (probe-file *tmp-jar-path*))
     114       (jar-file-init))
     115     (let ((*default-pathname-defaults* *tmp-directory*))
    117116       ,@body)))
    118117
     
    124123  `(with-jar-file-init
    125124       (load (jar-pathname-escaped ,jar ,path))))
     125
     126;;; XXX Figure out correct use of macros so this isn't necessary
     127(push 'jar-pathname.load.init *expected-failures*)
     128(deftest jar-pathname.load.init
     129    (with-jar-file-init
     130        nil)
     131  t)
    126132
    127133(deftest jar-pathname.load.1
     
    244250
    245251(deftest jar-pathname.probe-file.1
    246     (with-jar-file-init
    247         (probe-file "jar:file:baz.jar!/eek.lisp"))
    248   #p#.(format nil "jar:file:~A/baz.jar!/eek.lisp"
    249               (namestring *tmp-directory*)))
     252    (let ((result
     253           (with-jar-file-init
     254               (probe-file "jar:file:baz.jar!/eek.lisp"))))
     255      (string=
     256       (if result (namestring result) "")
     257       (format nil "jar:file:~Abaz.jar!/eek.lisp"
     258               (namestring *tmp-directory*))))
     259  t)
    250260
    251261(deftest jar-pathname.probe-file.2
    252     (with-jar-file-init
    253         (probe-file "jar:file:baz.jar!/a/b/bar.abcl"))
    254   #p#.(format nil "jar:file:~A/baz.jar!/a/b/bar.abcl"
    255               (namestring *tmp-directory*)))
     262    (let ((result
     263          (with-jar-file-init
     264              (probe-file "jar:file:baz.jar!/a/b/bar.abcl"))))
     265      (string=
     266       (if result (namestring result) "")
     267       (format nil "jar:file:~Abaz.jar!/a/b/bar.abcl"
     268               (namestring *tmp-directory*))))
     269  t)
    256270
    257271(deftest jar-pathname.probe-file.3
    258     (with-jar-file-init
    259         (probe-file "jar:jar:file:baz.jar!/a/b/bar.abcl!/bar._"))
    260    #p#.(format nil "jar:jar:file:~Abaz.jar!/a/b/bar.abcl!/bar._"
    261                        (namestring *tmp-directory*)))
     272    (let ((result
     273          (with-jar-file-init
     274              (probe-file "jar:jar:file:baz.jar!/a/b/bar.abcl!/bar._"))))
     275      (string=
     276       (if result (namestring result) "")
     277       (format nil "jar:jar:file:~Abaz.jar!/a/b/bar.abcl!/bar._"
     278               (namestring *tmp-directory*))))
     279  t)
     280
    262281
    263282(push 'jar-pathname.probe-file.4 *expected-failures*)
    264283(deftest jar-pathname.probe-file.4
    265     (with-jar-file-init
    266         (probe-file "jar:file:baz.jar!/a/b"))
    267   #p#.(format nil "jar:file:~Abaz.jar!/a/b/"
    268                        (namestring *tmp-directory*)))
     284    (let ((result
     285          (with-jar-file-init
     286              (probe-file "jar:file:baz.jar!/a/b"))))
     287      (string=
     288       (if result (namestring result) "")
     289       (format nil "jar:file:~Abaz.jar!/a/b/"
     290               (namestring *tmp-directory*))))
     291  t)
    269292
    270293(push 'jar-pathname.probe-file.5 *expected-failures*)
    271294(deftest jar-pathname.probe-file.5
    272     (with-jar-file-init
    273         (probe-file "jar:file:baz.jar!/a/b/"))
    274   #p#.(format nil "jar:file:~Abaz.jar!/a/b/"
    275                        (namestring *tmp-directory*)))
     295    (let ((result
     296          (with-jar-file-init
     297              (probe-file "jar:file:baz.jar!/a/b/"))))
     298      (string=
     299       (if result (namestring result) "")
     300       (format nil "jar:file:~Abaz.jar!/a/b/"
     301               (namestring *tmp-directory*))))
     302  t)
     303
    276304
    277305(deftest jar-pathname.probe-file.6
    278     (with-jar-file-init
    279         (probe-file "jar:file:baz.jar!/d/e+f/bar.abcl"))
    280   #p#.(format nil "jar:file:~Abaz.jar!/d/e+f/bar.abcl"
    281                        (namestring *tmp-directory*)))
     306    (let ((result
     307          (with-jar-file-init
     308              (probe-file "jar:file:baz.jar!/d/e+f/bar.abcl"))))
     309      (string=
     310       (if result (namestring result) "")
     311       (format nil "jar:file:~Abaz.jar!/d/e+f/bar.abcl"
     312               (namestring *tmp-directory*))))
     313  t)
    282314
    283315(deftest jar-pathname.merge-pathnames.1
Note: See TracChangeset for help on using the changeset viewer.