X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Frun.lisp;h=b2bbf24506dbc7512fabc6dc25b210fdb97ce0d9;hb=287c9bb8435332a4cb5f07fd4ef08c6a76c3499f;hp=2d1c898c8b4cb2258ad72462638dcaa20f0f2ed6;hpb=1454981ac5f4f7ea8fe741a8125efbf0b09497ea;p=fiveam.git diff --git a/src/run.lisp b/src/run.lisp index 2d1c898..b2bbf24 100644 --- a/src/run.lisp +++ b/src/run.lisp @@ -33,7 +33,7 @@ ;;;; The functions RUN!, !, !! and !!! are convenient wrappers around ;;;; RUN and EXPLAIN. -(defparameter *debug-on-error* t +(defparameter *debug-on-error* nil "T if we should drop into a debugger on error, NIL otherwise.") (defun import-testing-symbols (package-designator) @@ -104,19 +104,6 @@ run.")) (and (satisfies-depends-p #'every)) (or (satisfies-depends-p #'some)) (not (satisfies-depends-p #'notany)))))) - -(defun handle-unexpected-error (test error) - "Handler for unexpected conditions raised during test - execution." - (when (not *debug-on-error*) - (format *test-dribble* "F") - (with-run-state (result-list) - (push (make-instance 'unexpected-test-failure - :test-case test - :reason (format nil "Unexpected Error: ~S." error) - :condition test) - result-list) - (throw 'run-block result-list)))) (defun results-status (result-list) "Given a list of test results (generated while running a test) @@ -136,23 +123,34 @@ run.")) (defmethod run-test-lambda ((test test-case)) (with-run-state (result-list) - (catch 'run-block - (bind-run-state ((current-test test)) - (handler-bind ((error (lambda (e) (handle-unexpected-error test e)))) - (restart-case - (let ((results (return-result-list (test-lambda test)))) - (setf (status test) (results-status results) - result-list (nconc result-list results))) - (retest () - :report (lambda (stream) - (format stream "~@" test)) - (%run test)) - (ignore () - :report (lambda (stream) - (format stream "~@" test)) - (push (make-instance 'test-failure :test-case test - :reason "Failure restart.") - result-list)))))))) + (bind-run-state ((current-test test)) + (labels ((abort-test (e) + (add-result 'unexpected-test-failure + :test-case test + :reason (format nil "Unexpected Error: ~S." e) + :condition e)) + (run-it () + (let ((result-list '())) + (declare (special result-list)) + (handler-bind ((error (lambda (e) + (unless *debug-on-error* + (abort-test e) + (return-from run-it result-list))))) + (restart-case + (funcall (test-lambda test)) + (retest () + :report (lambda (stream) + (format stream "~@" test)) + (return-from run-it (run-it))) + (ignore () + :report (lambda (stream) + (format stream "~@" test)) + (abort-test (make-instance 'test-failure :test-case test + :reason "Failure restart.")))) + result-list)))) + (let ((results (run-it))) + (setf (status test) (results-status results) + result-list (nconc result-list results))))))) (defgeneric %run (test-spec) (:documentation "Internal method for running a test. Does not