X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-cover%2Fcover.lisp;h=28ead428e959f2424e13aad7068c7392d1b91a62;hb=137b4d09b88273bbd3a4295d8c98a5dad4e75ec7;hp=d697492a6c2b615cec95ba58ebafc46b58cd7290;hpb=77a7ce93218e71f21268661611530a129002a8e6;p=sbcl.git diff --git a/contrib/sb-cover/cover.lisp b/contrib/sb-cover/cover.lisp index d697492..28ead42 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 + :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. @@ -92,11 +105,14 @@ 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)))) + (*default-pathname-defaults* (pathname-as-directory directory))) (ensure-directories-exist *default-pathname-defaults*) (maphash (lambda (k v) (declare (ignore v)) - (let* ((n (substitute #\_ #\. (substitute #\_ #\/ k))) + (let* ((n (format nil "~(~{~2,'0X~}~)" + (coerce (sb-md5:md5sum-string + (sb-ext:native-namestring k)) + 'list))) (path (make-pathname :name n :type "html"))) (when (probe-file k) (with-open-file (stream path