X-Git-Url: http://git.kpe.io/?p=xlunit.git;a=blobdiff_plain;f=printer.lisp;h=ad351c8e7012efa88fef24a670b541c9bedc6acc;hp=3637ff454f4b1c49e069a21f676e55d19040fa82;hb=3d99efdf0959b199cc4b2e020c7692f650094f73;hpb=6c233c812b0e160d80e613bb3dfcedc59514e3e9 diff --git a/printer.lisp b/printer.lisp index 3637ff4..ad351c8 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.6 2003/08/05 22:56:25 kevin Exp $ ;;;; Purpose: Printer functions for XLUnit ;;;; ;;;; ************************************************************************* @@ -14,51 +14,50 @@ ; 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))) + (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)))))))) + + +(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))