From: Thomas M. Hermann Date: Fri, 1 Feb 2013 05:09:22 +0000 (-0600) Subject: Optionally signal results. X-Git-Tag: 0.9.4~1^2~6 X-Git-Url: https://repo.or.cz/w/lisp-unit.git/commitdiff_plain/ae378438928e5237b19742eced9107a5e6d4afe3 Optionally signal results. --- diff --git a/lisp-unit.lisp b/lisp-unit.lisp index b63724c..80cbd67 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -91,7 +91,8 @@ functions or even macros does not require reloading any tests. :print-errors :summarize-results) ;; Functions for extensibility via signals - (:export :test-run-complete + (:export :signal-results + :test-run-complete :results) ;; Utility predicates (:export :logically-equal :set-equal)) @@ -125,6 +126,9 @@ functions or even macros does not require reloading any tests. "If not NIL, enter the debugger when an error is encountered in an assertion.") +(defparameter *signal-results* nil + "Signal the result if non NIL.") + (defun use-debugger-p (condition) "Debug or ignore errors." (cond @@ -136,6 +140,17 @@ assertion.") "Use the debugger when testing, or not." (setq *use-debugger* flag)) +(defun signal-results (&optional (flag t)) + "Signal the results for extensibility." + (setq *signal-results* flag)) + +(define-condition test-run-complete () + ((results + :initarg :results + :reader results)) + (:documentation + "Signaled when a test run is finished.")) + ;;; Global unit test database (defparameter *test-db* (make-hash-table :test #'eq) @@ -636,9 +651,6 @@ assertion.") (length (missing-tests results))))) ;;; Run the tests -(define-condition test-run-complete () - ((results :initarg :results :reader results)) - (:documentation "signaled when a test run is finished")) (defun %run-all-thunks (&optional (package *package*)) "Run all of the test thunks in the package." @@ -652,8 +664,9 @@ assertion.") (push test-name (missing-tests results)) ;; Summarize and return the test results finally + (when *signal-results* + (signal 'test-run-complete :results results)) (summarize-results results) - (signal 'test-run-complete :results results) (return results))) (defun %run-thunks (test-names &optional (package *package*)) @@ -668,8 +681,9 @@ assertion.") else do (push test-name (missing-tests results)) finally + (when *signal-results* + (signal 'test-run-complete :results results)) (summarize-results results) - (signal 'test-run-complete :results results) (return results))) (defun run-tests (test-names &optional (package *package*))