Function: ert-run-tests-interactively
ert-run-tests-interactively is an autoloaded, interactive and
byte-compiled function defined in ert.el.gz.
Signature
(ert-run-tests-interactively SELECTOR &optional OUTPUT-BUFFER-NAME MESSAGE-FN)
Documentation
Run the tests specified by SELECTOR and display the results in a buffer.
SELECTOR works as described in ert-select-tests.
OUTPUT-BUFFER-NAME and MESSAGE-FN should normally be nil; they
are used for automated self-tests and specify which buffer to use
and how to display message.
Key Bindings
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/ert.el.gz
;; Should OUTPUT-BUFFER-NAME and MESSAGE-FN really be arguments here?
;; They are needed only for our automated self-tests at the moment.
;; Or should there be some other mechanism?
;;;###autoload
(defun ert-run-tests-interactively (selector
&optional output-buffer-name message-fn)
"Run the tests specified by SELECTOR and display the results in a buffer.
SELECTOR works as described in `ert-select-tests'.
OUTPUT-BUFFER-NAME and MESSAGE-FN should normally be nil; they
are used for automated self-tests and specify which buffer to use
and how to display message."
(interactive
(list (let ((default (if ert--selector-history
;; Can't use `first' here as this form is
;; not compiled, and `first' is not
;; defined without cl.
(car ert--selector-history)
"t")))
(read
(completing-read (format-prompt "Run tests" default)
obarray #'ert-test-boundp nil nil
'ert--selector-history default nil)))
nil))
(unless message-fn (setq message-fn 'message))
(let ((output-buffer-name output-buffer-name)
buffer
listener
(message-fn message-fn))
(setq listener
(lambda (event-type &rest event-args)
(cl-ecase event-type
(run-started
(cl-destructuring-bind (stats) event-args
(setq buffer (ert--setup-results-buffer stats
listener
output-buffer-name))
(pop-to-buffer buffer)))
(run-ended
(cl-destructuring-bind (stats abortedp) event-args
(funcall message-fn
"%sRan %s tests, %s results were as expected%s%s"
(if (not abortedp)
""
"Aborted: ")
(ert-stats-total stats)
(ert-stats-completed-expected stats)
(let ((unexpected
(ert-stats-completed-unexpected stats)))
(if (zerop unexpected)
""
(format ", %s unexpected" unexpected)))
(let ((skipped
(ert-stats-skipped stats)))
(if (zerop skipped)
""
(format ", %s skipped" skipped))))
(ert--results-update-stats-display (with-current-buffer buffer
ert--results-ewoc)
stats)))
(test-started
(cl-destructuring-bind (stats test) event-args
(with-current-buffer buffer
(let* ((ewoc ert--results-ewoc)
(pos (ert--stats-test-pos stats test))
(node (ewoc-nth ewoc pos)))
(cl-assert node)
(setf (ert--ewoc-entry-test (ewoc-data node)) test)
(aset ert--results-progress-bar-string pos
(ert-char-for-test-result nil t))
(ert--results-update-stats-display-maybe ewoc stats)
(ewoc-invalidate ewoc node)))))
(test-ended
(cl-destructuring-bind (stats test result) event-args
(with-current-buffer buffer
(let* ((ewoc ert--results-ewoc)
(pos (ert--stats-test-pos stats test))
(node (ewoc-nth ewoc pos)))
(when (ert--ewoc-entry-hidden-p (ewoc-data node))
(setf (ert--ewoc-entry-hidden-p (ewoc-data node))
(ert-test-result-expected-p test result)))
(aset ert--results-progress-bar-string pos
(ert-char-for-test-result result
(ert-test-result-expected-p
test result)))
(ert--results-update-stats-display-maybe ewoc stats)
(ewoc-invalidate ewoc node))))))))
(ert-run-tests selector listener t)))