diff --git a/runner.lisp b/runner.lisp index 1d7c5e7..f47ae6f 100644 --- a/runner.lisp +++ b/runner.lisp @@ -22,8 +22,6 @@ #:getenv) (:import-from #:ace.core.macro #:eval-always) - (:import-from #:ace.core.hook - #:define-hook-function) (:import-from #:ace.core.check.condition #:failed #:missed @@ -37,7 +35,7 @@ #:make-schedule #:nothing-tested #:run-tests - #:report-tests + #:*reporting-hooks* #:run-and-report-tests #:deregister-tests #:*debug-unit-tests* @@ -538,12 +536,12 @@ If PARALLEL is NIL, the PARALLEL tests will be empty.")) all-count check-count failed-count)) (zerop failed-count)))) -(define-hook-function report-tests (tests &key out) - :documentation - "Called to report the TESTS from RUN-AND-REPORT-TESTS. The TESTS is a list of TEST-RUN objects. - OUT specifies the default output stream to which the report is printed.") - -(defmethod report-tests print-summary-and-failures (tests &key (out *error-output*)) +(defvar *reporting-hooks* nil "User-specified final report functions") +(defun report-tests (tests &key (out *error-output*)) + (dolist (hook *reporting-hooks*) + (handler-case (funcall hook tests :out out) + (:no-error (&rest vals) (values-list vals)) + (error (e) (format t "Caught [~A] while trying to run reporting hook" e)))) (let ((fail-count (count-if #'test-run-error tests)) (all-count (length tests)) (checks-count (loop for test-run in tests sum (test-run-checks-count test-run)))) diff --git a/xml-report.lisp b/xml-report.lisp index c428b54..a344f43 100644 --- a/xml-report.lisp +++ b/xml-report.lisp @@ -21,7 +21,6 @@ #:function-file-path) (:import-from #:ace.test.runner #:with-sane-io-syntax - #:report-tests #:test-run #:test-run-test #:test-run-error @@ -178,7 +177,7 @@ (group-and-print-test-cases test-cases :key #'test-package-name :out out) (format out "~&~%")) -(defmethod report-tests dump-junit-xml-output (test-cases &key &allow-other-keys) +(defun dump-junit-xml-output (test-cases &key &allow-other-keys) (let ((xml-output (getenv "XML_OUTPUT_FILE"))) ;; This variable is specified here: @@ -192,3 +191,4 @@ :element-type 'character :external-format :utf-8) (print-tests-report test-cases out))))) +(pushnew 'dump-junit-xml-output ace.test.runner:*reporting-hooks*)