Function: ert--run-test-debugger
ert--run-test-debugger is a byte-compiled function defined in
ert.el.gz.
Signature
(ert--run-test-debugger INFO CONDITION DEBUGFUN)
Documentation
Error handler used during the test run.
This function records failures and errors and either terminates the test silently or calls the interactive debugger, as appropriate.
INFO is the ert--test-execution-info corresponding to this test run.
ERR is the error object.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/ert.el.gz
(defun ert--run-test-debugger (info condition debugfun)
"Error handler used during the test run.
This function records failures and errors and either terminates
the test silently or calls the interactive debugger, as
appropriate.
INFO is the `ert--test-execution-info' corresponding to this test run.
ERR is the error object."
(let* ((type (cl-case (car condition)
((quit) 'quit)
((ert-test-skipped) 'skipped)
(otherwise 'failed)))
;; We store the backtrace in the result object for
;; `ert-results-pop-to-backtrace-for-test-at-point'.
;; This means we have to limit `print-level' and
;; `print-length' when printing result objects. That
;; might not be worth while when we can also use
;; `ert-results-rerun-test-at-point-debugging-errors',
;; (i.e., when running interactively) but having the
;; backtrace ready for printing is important for batch
;; use.
;;
;; Grab the frames above ourselves.
(backtrace (cdr (backtrace-get-frames debugfun)))
(infos (reverse ert--infos)))
(setf (ert--test-execution-info-result info)
(cl-ecase type
(quit
(make-ert-test-quit :condition condition
:backtrace backtrace
:infos infos))
(skipped
(make-ert-test-skipped :condition condition
:backtrace backtrace
:infos infos))
(failed
(make-ert-test-failed :condition condition
:backtrace backtrace
:infos infos))))
;; FIXME: We should probably implement more fine-grained
;; control a la non-t `debug-on-error' here.
(cond
((ert--test-execution-info-ert-debug-on-error info)
;; The `debugfun' arg tells `debug' which backtrace frame starts
;; the "entering the debugger" code so it can hide those frames
;; from the backtrace.
(funcall debugger 'error condition :backtrace-base debugfun))
(t))
(funcall (ert--test-execution-info-exit-continuation info))))