Commit 5aa405f6 authored by Mark's avatar Mark
Browse files

Test for zip-cache contents

TODO: test for more than singly nested zip entries.
parent cf610d56
......@@ -5,6 +5,116 @@
(p (make-pathname :host nil :defaults uri)))
(prove:like (namestring p) "^/directory/name.version$"))
(defparameter *removable-artifacts* nil)
(defun create-zip ()
(uiop:with-temporary-file (:pathname tmp :type "zip" :keep t)
(let* ((file
(compile-file file))
(rename-file file (make-pathname :defaults file :name "output-date")))
(rename-file fasl (make-pathname :defaults fasl :name "output-date")))
`(,renamed-file ,renamed-fasl))
(sys:zip tmp contents)))
(dolist (file (list renamed-file renamed-fasl zipfile))
(pushnew file *removable-artifacts*))
(defun create-file ()
(uiop:with-temporary-file (:stream s :pathname p :keep t :type "lisp")
`(format t "~s ~s~%" ,(get-universal-time) (symbol-name (gensym)))
:stream s)
(prove:plan 5)
(let* ((zip-1
(sleep 1.5)
(make-pathname :defaults zip-1 :type "tmp"))
(make-pathname :defaults zip-2 :type "tmp"))
(ext:as-jar-pathname-archive zip-1))
(ext:as-jar-pathname-archive zip-2))
(merge-pathnames "output-date.lisp" zip-1-path))
(merge-pathnames "output-date.lisp" zip-2-path))
(merge-pathnames "output-date.abcl" zip-1-path))
(merge-pathnames "output-date.abcl" zip-2-path)))
(uiop:copy-file zip-1 zip-tmp-1)
(uiop:copy-file zip-2 zip-tmp-2)
;;; If the first two tests fail, we have not setup the test correctly
;;; FIXME: how to bail on the remaining tests early?
(let ((zip-1-date (file-write-date zip-1))
(zip-2-date (file-write-date zip-2)))
(not (equal zip-1-date zip-2-date))
(format nil "Archives have different times~%~a ~a~%~a ~a~%"
zip-1-date zip-1
zip-2-date zip-2)))
(let ((date-1 (file-write-date zip-1-entry-1))
(date-2 (file-write-date zip-2-entry-1)))
(not (equal date-1 date-2))
(format nil "Archive entries have different times~%~a <~a>~%~a <~a>~%"
date-1 zip-1-entry-1
date-2 zip-2-entry-1)))
(let ((date-1 (file-write-date zip-1-path)))
(sleep 1)
(rename-file zip-2 zip-1)
(let ((date-2 (file-write-date zip-1-path)))
(not (equal date-1 date-2))
(format nil "ZipCache recomputes date on JAR-PATHNAME archive~%<~a>~%~a ~a~%"
zip-1-path date-1 date-2))))
(uiop:copy-file zip-tmp-1 zip-1)
(uiop:copy-file zip-tmp-2 zip-2)
(let ((date-1 (file-write-date zip-1-entry-1)))
(sleep 1.1)
(rename-file zip-2 zip-1)
(let ((date-2 (file-write-date zip-1-entry-1)))
(not (equal date-1 date-2))
(format nil "ZipCache recomputes JAR-PATHNAME entry dates~%<~a>~%~a ~a~%"
date-1 date-2))))
(uiop:copy-file zip-tmp-1 zip-1)
(uiop:copy-file zip-tmp-2 zip-2)
(let* ((entry
(make-pathname :defaults (ext:as-jar-pathname-archive zip-1-entry-2)
:name "__loader__" :type "_"))
(file-write-date entry)))
(sleep 1.1)
(rename-file zip-2 zip-1)
(let ((date-2 (file-write-date entry)))
(not (equal date-1 date-2))
(format nil "ZipCache recomputes singly nested JAR-PATHNAME entry dates~%<~a>~%~a ~a~%"
date-1 date-2)))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment