diff options
| author | Philipp Stephani | 2020-12-07 21:41:40 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2020-12-07 21:41:40 +0100 |
| commit | 0155bd0fdb166c97a2ce76cc5bc64fd195a676d3 (patch) | |
| tree | 0746cc2410658fc03931dfeb942cd8b477965dd4 | |
| parent | 0c330bed24ef045732a1bfe61d20ed8328dd0b28 (diff) | |
| download | emacs-0155bd0fdb166c97a2ce76cc5bc64fd195a676d3.tar.gz emacs-0155bd0fdb166c97a2ce76cc5bc64fd195a676d3.zip | |
Fix bug in how ERT invokes its debugger.
The debugger needs to receive a list of the error symbol and data;
cf. the documentation of the `debugger' variable. This bug manifested
itself in ERT forms such as (should (integerp (ert-fail "Boo"))),
which resulted in an incorrect condition object. Note that forms such
as (should (ert-fail "Boo")) weren't affected because they wouldn't
use the `ert--should-signal-hook'.
* test/emacs-lisp/ert.el (ert--should-signal-hook): Call debugger with
the right arguments.
* test/lisp/emacs-lisp/ert-tests.el (ert-test-fail-inside-should): Add
unit test.
| -rw-r--r-- | lisp/emacs-lisp/ert.el | 2 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/ert-tests.el | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 5f29c2665a3..25237feae2a 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el | |||
| @@ -274,7 +274,7 @@ DATA is displayed to the user and should state the reason for skipping." | |||
| 274 | It should only be stopped when ran from inside ert--run-test-internal." | 274 | It should only be stopped when ran from inside ert--run-test-internal." |
| 275 | (when (and (not (symbolp debugger)) ; only run on anonymous debugger | 275 | (when (and (not (symbolp debugger)) ; only run on anonymous debugger |
| 276 | (memq error-symbol '(ert-test-failed ert-test-skipped))) | 276 | (memq error-symbol '(ert-test-failed ert-test-skipped))) |
| 277 | (funcall debugger 'error data))) | 277 | (funcall debugger 'error (list error-symbol data)))) |
| 278 | 278 | ||
| 279 | (defun ert--special-operator-p (thing) | 279 | (defun ert--special-operator-p (thing) |
| 280 | "Return non-nil if THING is a symbol naming a special operator." | 280 | "Return non-nil if THING is a symbol naming a special operator." |
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 1f54c8d07e4..a0c56be0cb0 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el | |||
| @@ -806,6 +806,16 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 806 | :expected-result :failed ;; FIXME! Bug#11218 | 806 | :expected-result :failed ;; FIXME! Bug#11218 |
| 807 | (should-not (with-demoted-errors (error "Foo")))) | 807 | (should-not (with-demoted-errors (error "Foo")))) |
| 808 | 808 | ||
| 809 | (ert-deftest ert-test-fail-inside-should () | ||
| 810 | "Check that `ert-fail' inside `should' works correctly." | ||
| 811 | (let ((result (ert-run-test | ||
| 812 | (make-ert-test | ||
| 813 | :name 'test-1 | ||
| 814 | :body (lambda () (should (integerp (ert-fail "Boo")))))))) | ||
| 815 | (should (ert-test-failed-p result)) | ||
| 816 | (should (equal (ert-test-failed-condition result) | ||
| 817 | '(ert-test-failed ("Boo")))))) | ||
| 818 | |||
| 809 | 819 | ||
| 810 | (provide 'ert-tests) | 820 | (provide 'ert-tests) |
| 811 | 821 | ||