X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-cover%2Fcover.lisp;h=957954b74cdffa9ca2d96e607a2d92f993b7662e;hb=3db292921fabecad0ba8107097d763ba2a044136;hp=c273b8609925d66e4218d5970e3abf6e5af2495e;hpb=b8f49ceae4a3b513de21f385bb784729d2ddff3f;p=sbcl.git diff --git a/contrib/sb-cover/cover.lisp b/contrib/sb-cover/cover.lisp index c273b86..957954b 100644 --- a/contrib/sb-cover/cover.lisp +++ b/contrib/sb-cover/cover.lisp @@ -79,6 +79,19 @@ result to RESTORE-COVERAGE." (restore-coverage (read stream)))) (values))) +(defun pathname-as-directory (pathname &optional (errorp t)) + (let ((pathname (merge-pathnames pathname))) + (if (and (member (pathname-name pathname) '(nil :unspecific)) + (member (pathname-type pathname) '(nil :unspecific))) + pathname + (if errorp + (error "~S does not designate a directory" pathname) + (make-pathname :directory (append (or (pathname-directory pathname) + (list :relative)) + (list (file-namestring pathname))) + :name nil :type nil :version nil + :defaults pathname))))) + (defun report (directory &key ((:form-mode *source-path-mode*) :whole) (external-format :default)) "Print a code coverage report of all instrumented files into DIRECTORY. @@ -91,17 +104,20 @@ the coverage report will be placed on the CARs of any cons-forms, while if it has the value :WHOLE the whole form will be annotated (the default). The former mode shows explicitly which forms were instrumented, while the latter mode is generally easier to read." - (let ((paths) - (*default-pathname-defaults* (merge-pathnames (pathname directory)))) + (let* ((paths) + (directory (pathname-as-directory directory)) + (*default-pathname-defaults* (translate-logical-pathname directory))) (ensure-directories-exist *default-pathname-defaults*) (maphash (lambda (k v) (declare (ignore v)) - (let* ((n (format nil "~(~{~2,'0X~}~)" + (let* ((pk (translate-logical-pathname k)) + (n (format nil "~(~{~2,'0X~}~)" (coerce (sb-md5:md5sum-string - (sb-ext:native-namestring k)) + (sb-ext:native-namestring pk)) 'list))) - (path (make-pathname :name n :type "html"))) + (path (make-pathname :name n :type "html" :defaults directory))) (when (probe-file k) + (ensure-directories-exist pk) (with-open-file (stream path :direction :output :if-exists :supersede @@ -109,7 +125,7 @@ latter mode is generally easier to read." (push (list* k n (report-file k stream external-format)) paths))))) *code-coverage-info*) - (let ((report-file (make-pathname :name "cover-index" :type "html"))) + (let ((report-file (make-pathname :name "cover-index" :type "html" :defaults directory))) (with-open-file (stream report-file :direction :output :if-exists :supersede :if-does-not-exist :create)