X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=printer.lisp;h=8cfeab9f7c3c8aba3a6a28d5fe298b0f9bb9cbdf;hb=0114e93940d17c3dd840f37a81d6fb0da66e7a25;hp=3637ff454f4b1c49e069a21f676e55d19040fa82;hpb=6e195606e06173086a91616042adef3072633d92;p=xlunit.git diff --git a/printer.lisp b/printer.lisp index 3637ff4..8cfeab9 100644 --- a/printer.lisp +++ b/printer.lisp @@ -2,7 +2,7 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; ID: $Id: printer.lisp,v 1.5 2003/08/04 19:31:34 kevin Exp $ +;;;; ID: $Id: printer.lisp,v 1.7 2003/08/10 07:39:33 kevin Exp $ ;;;; Purpose: Printer functions for XLUnit ;;;; ;;;; ************************************************************************* @@ -14,51 +14,54 @@ ; method print-results ;---------------------------------------------------------------------- -(defmethod print-results ((ob textui-test-runner) result seconds) - (format (ostream ob) "~&Time: ~D~%~%" (coerce seconds 'float)) - (print-header ob result) - (print-errors ob result) - (print-failures ob result) - t) +(defmethod print-results ((obj textui-test-runner) result seconds) + (print-header obj result seconds) + (print-defects obj (errors result) "error") + (print-defects obj (failures result) "failure") + (print-footer obj result) + (values)) -(defmethod print-header ((ob textui-test-runner) result) +(defmethod print-header ((obj textui-test-runner) result seconds) + (declare (ignore result)) + (format (ostream obj) "~&Time: ~D~%~%" (coerce seconds 'float))) + +(defmethod print-defects ((obj textui-test-runner) defects title) + (when defects + (let ((count (length defects))) + (if (= 1 count) + (format (ostream obj) "~%There was 1 ~A:~%" title) + (format (ostream obj) "~%There were ~D ~A:~%" + count title)) + (dotimes (i count) + (let* ((defect (nth i defects)) + (condition (thrown-condition defect))) + (format (ostream obj) "~A) ~A: " + (1+ i) (name (failed-test defect))) + (typecase condition + (assertion-failed + (apply #'format (ostream obj) + (simple-condition-format-control condition) + (simple-condition-format-arguments condition)) + (format (ostream obj) "~%") + (when (message condition) + (let ((spaces (+ 2 (length (format nil "~D" count))))) + (dotimes (i spaces) + (write-char #\space (ostream obj)))) + (format (ostream obj) "~A~%" (message condition)))) + (t + (format (ostream obj) "~A~%" condition)))))))) + + +(defmethod print-footer ((obj textui-test-runner) result) (let ((failures (failures result)) (errors (errors result)) (run-tests (run-tests result))) (cond ((and (null failures) (null errors)) - (format (ostream ob) "~%OK (~a tests)~%" run-tests)) + (format (ostream obj) "~%OK (~a tests)~%" run-tests)) (t - (format (ostream ob) "~%~%FAILURES!!!~%") - (format (ostream ob) "Run: ~a Failures: ~a Errors: ~a~%" + (format (ostream obj) "~%~%FAILURES!!!~%") + (format (ostream obj) "Run: ~a Failures: ~a Errors: ~a~%" run-tests (length failures) (length errors)))))) - -(defmethod print-errors ((ob textui-test-runner) result) - (let ((errors (errors result))) - (when errors - (if (eql (length errors) 1) - (format (ostream ob) "~%There was 1 error:~%") - (format (ostream ob) "~%There were ~a errors:~%" (length errors))) - (let ((i 1)) - (mapc #'(lambda (single-error) - (format (ostream ob) "~a) ~a: ~a~%" i - (name (failed-test single-error)) - (thrown-condition single-error)) - (incf i)) - errors))))) - -(defmethod print-failures ((ob textui-test-runner) result) - (let ((failures (failures result))) - (when failures - (if (eql (length failures) 1) - (format (ostream ob) "~%There was 1 failure:~%") - (format (ostream ob) "~%There were ~a failures:~%" (length failures))) - (let ((i 1)) - (mapc #'(lambda (single-failure) - (format (ostream ob) "~a) ~a: ~a~%" i - (name (failed-test single-failure)) - (or (message (thrown-condition single-failure)) "")) - (incf i)) - failures))))) (defgeneric summary (result)) (defmethod summary ((result test-results))