mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 02:31:03 -08:00
Allow ERT tests to output the failure reasons, too
* lisp/emacs-lisp/ert.el (ert-reason-for-test-result): New function. (ert-run-tests-batch): Output failure or skip reason (bug#47071).
This commit is contained in:
parent
81fd5603ce
commit
8be9d4a156
3 changed files with 38 additions and 4 deletions
|
|
@ -347,6 +347,10 @@ emacs -batch -l ert -l my-tests.el \
|
||||||
-eval '(ert-run-tests-batch-and-exit "to-match")'
|
-eval '(ert-run-tests-batch-and-exit "to-match")'
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
By default, ERT test failure summaries are quite brief in batch
|
||||||
|
mode--only the names of the failed tests are listed. If the
|
||||||
|
EMACS_TEST_VERBOSE environment variable is set, the failure summaries
|
||||||
|
will also include the data from the failing test.
|
||||||
|
|
||||||
@node Test Selectors
|
@node Test Selectors
|
||||||
@section Test Selectors
|
@section Test Selectors
|
||||||
|
|
|
||||||
7
etc/NEWS
7
etc/NEWS
|
|
@ -2090,6 +2090,13 @@ This allows mode-specific alterations to how 'thing-at-point' works.
|
||||||
This is so 'C-a' works as in other modes, and in particular holding
|
This is so 'C-a' works as in other modes, and in particular holding
|
||||||
Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text.
|
Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text.
|
||||||
|
|
||||||
|
** ERT
|
||||||
|
|
||||||
|
+++
|
||||||
|
*** ERT can now output more verbose test failure reports.
|
||||||
|
If the EMACS_TEST_VERBOSE environment variable is set, failure
|
||||||
|
summaries will include the failing condition.
|
||||||
|
|
||||||
** Miscellaneous
|
** Miscellaneous
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
|
||||||
|
|
@ -1279,6 +1279,23 @@ EXPECTEDP specifies whether the result was expected."
|
||||||
(ert-test-quit '("quit" "QUIT")))))
|
(ert-test-quit '("quit" "QUIT")))))
|
||||||
(elt s (if expectedp 0 1))))
|
(elt s (if expectedp 0 1))))
|
||||||
|
|
||||||
|
(defun ert-reason-for-test-result (result)
|
||||||
|
"Return the reason given for RESULT, as a string.
|
||||||
|
|
||||||
|
The reason is the argument given when invoking `ert-fail' or `ert-skip'.
|
||||||
|
It is output using `prin1' prefixed by two spaces.
|
||||||
|
|
||||||
|
If no reason was given, or for a successful RESULT, return the
|
||||||
|
empty string."
|
||||||
|
(let ((reason
|
||||||
|
(and
|
||||||
|
(ert-test-result-with-condition-p result)
|
||||||
|
(cadr (ert-test-result-with-condition-condition result))))
|
||||||
|
(print-escape-newlines t)
|
||||||
|
(print-level 6)
|
||||||
|
(print-length 10))
|
||||||
|
(if reason (format " %S" reason) "")))
|
||||||
|
|
||||||
(defun ert--pp-with-indentation-and-newline (object)
|
(defun ert--pp-with-indentation-and-newline (object)
|
||||||
"Pretty-print OBJECT, indenting it to the current column of point.
|
"Pretty-print OBJECT, indenting it to the current column of point.
|
||||||
Ensures a final newline is inserted."
|
Ensures a final newline is inserted."
|
||||||
|
|
@ -1369,18 +1386,24 @@ Returns the stats object."
|
||||||
(cl-loop for test across (ert--stats-tests stats)
|
(cl-loop for test across (ert--stats-tests stats)
|
||||||
for result = (ert-test-most-recent-result test) do
|
for result = (ert-test-most-recent-result test) do
|
||||||
(when (not (ert-test-result-expected-p test result))
|
(when (not (ert-test-result-expected-p test result))
|
||||||
(message "%9s %S"
|
(message "%9s %S%s"
|
||||||
(ert-string-for-test-result result nil)
|
(ert-string-for-test-result result nil)
|
||||||
(ert-test-name test))))
|
(ert-test-name test)
|
||||||
|
(if (getenv "EMACS_TEST_VERBOSE")
|
||||||
|
(ert-reason-for-test-result result)
|
||||||
|
""))))
|
||||||
(message "%s" ""))
|
(message "%s" ""))
|
||||||
(unless (zerop skipped)
|
(unless (zerop skipped)
|
||||||
(message "%s skipped results:" skipped)
|
(message "%s skipped results:" skipped)
|
||||||
(cl-loop for test across (ert--stats-tests stats)
|
(cl-loop for test across (ert--stats-tests stats)
|
||||||
for result = (ert-test-most-recent-result test) do
|
for result = (ert-test-most-recent-result test) do
|
||||||
(when (ert-test-result-type-p result :skipped)
|
(when (ert-test-result-type-p result :skipped)
|
||||||
(message "%9s %S"
|
(message "%9s %S%s"
|
||||||
(ert-string-for-test-result result nil)
|
(ert-string-for-test-result result nil)
|
||||||
(ert-test-name test))))
|
(ert-test-name test)
|
||||||
|
(if (getenv "EMACS_TEST_VERBOSE")
|
||||||
|
(ert-reason-for-test-result result)
|
||||||
|
""))))
|
||||||
(message "%s" "")))))
|
(message "%s" "")))))
|
||||||
(test-started
|
(test-started
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue