diff options
| author | Stefan Monnier | 2023-12-28 00:46:36 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2024-01-04 16:34:13 -0500 |
| commit | 25ea99c211ecf91735b44172da19fc53b304c5f4 (patch) | |
| tree | 5cabb7778ec6227af07fb45cd792d1d2444a17f5 /test | |
| parent | fe0f15dbc962b37d98507a494fd7720bad584a7a (diff) | |
| download | emacs-25ea99c211ecf91735b44172da19fc53b304c5f4.tar.gz emacs-25ea99c211ecf91735b44172da19fc53b304c5f4.zip | |
Fix ert-tests.el for the new `handler-bind` code
Now that `ert.el` uses `handler-bind` instead of `debugger`, some
details of the behavior have changed. More specifically,
three tests are now broken, but these basically tested the failure
of ERT's machinery to record errors when ERT was run within
a `condition-case`.
AFAICT, these tests do not check for a behavior that we want,
so rather than "fix" them, I deleted them (bug#67862).
* test/lisp/emacs-lisp/ert-tests.el (ert-test-error-debug)
(ert-test-fail-debug-with-condition-case): Delete.
(ert-test-should-failure-debugging): Don't use `ert-debug-on-error`.
(ert-test-with-demoted-errors): It now passes. Bug#11218 is fixed!
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/ert-tests.el | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 768a3a726aa..1aff73d66f6 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; ert-tests.el --- ERT's self-tests -*- lexical-binding: t -*- | 1 | ;;; ert-tests.el --- ERT's self-tests -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2007-2024 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Christian Ohler <ohler@gnu.org> | 5 | ;; Author: Christian Ohler <ohler@gnu.org> |
| 6 | 6 | ||
| @@ -93,16 +93,6 @@ failed or if there was a problem." | |||
| 93 | '(ert-test-failed "failure message")) | 93 | '(ert-test-failed "failure message")) |
| 94 | t)))) | 94 | t)))) |
| 95 | 95 | ||
| 96 | (ert-deftest ert-test-fail-debug-with-condition-case () | ||
| 97 | (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) | ||
| 98 | (condition-case condition | ||
| 99 | (progn | ||
| 100 | (let ((ert-debug-on-error t)) | ||
| 101 | (ert-run-test test)) | ||
| 102 | (cl-assert nil)) | ||
| 103 | ((error) | ||
| 104 | (cl-assert (equal condition '(ert-test-failed "failure message")) t))))) | ||
| 105 | |||
| 106 | (ert-deftest ert-test-fail-debug-with-debugger-1 () | 96 | (ert-deftest ert-test-fail-debug-with-debugger-1 () |
| 107 | (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) | 97 | (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) |
| 108 | (let ((debugger (lambda (&rest _args) | 98 | (let ((debugger (lambda (&rest _args) |
| @@ -146,16 +136,6 @@ failed or if there was a problem." | |||
| 146 | '(error "Error message")) | 136 | '(error "Error message")) |
| 147 | t)))) | 137 | t)))) |
| 148 | 138 | ||
| 149 | (ert-deftest ert-test-error-debug () | ||
| 150 | (let ((test (make-ert-test :body (lambda () (error "Error message"))))) | ||
| 151 | (condition-case condition | ||
| 152 | (progn | ||
| 153 | (let ((ert-debug-on-error t)) | ||
| 154 | (ert-run-test test)) | ||
| 155 | (cl-assert nil)) | ||
| 156 | ((error) | ||
| 157 | (cl-assert (equal condition '(error "Error message")) t))))) | ||
| 158 | |||
| 159 | 139 | ||
| 160 | ;;; Test that `should' works. | 140 | ;;; Test that `should' works. |
| 161 | (ert-deftest ert-test-should () | 141 | (ert-deftest ert-test-should () |
| @@ -359,14 +339,10 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 359 | (,(lambda () (let ((_x t)) (should (error "Foo")))) | 339 | (,(lambda () (let ((_x t)) (should (error "Foo")))) |
| 360 | (error "Foo"))) | 340 | (error "Foo"))) |
| 361 | do | 341 | do |
| 362 | (let ((test (make-ert-test :body body))) | 342 | (let* ((test (make-ert-test :body body)) |
| 363 | (condition-case actual-condition | 343 | (result (ert-run-test test))) |
| 364 | (progn | 344 | (should (ert-test-failed-p result)) |
| 365 | (let ((ert-debug-on-error t)) | 345 | (should (equal (ert-test-failed-condition result) expected-condition))))) |
| 366 | (ert-run-test test)) | ||
| 367 | (cl-assert nil)) | ||
| 368 | ((error) | ||
| 369 | (should (equal actual-condition expected-condition))))))) | ||
| 370 | 346 | ||
| 371 | (defun ert-test--which-file () | 347 | (defun ert-test--which-file () |
| 372 | "Dummy function to help test `symbol-file' for tests.") | 348 | "Dummy function to help test `symbol-file' for tests.") |
| @@ -392,9 +368,9 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 392 | (result (ert-run-test test))) | 368 | (result (ert-run-test test))) |
| 393 | (should (ert-test-failed-p result)) | 369 | (should (ert-test-failed-p result)) |
| 394 | (should (memq (backtrace-frame-fun (car (ert-test-failed-backtrace result))) | 370 | (should (memq (backtrace-frame-fun (car (ert-test-failed-backtrace result))) |
| 395 | ;;; This is `ert-fail' on nativecomp and `signal' | 371 | ;; This is `ert-fail' on nativecomp and `signal' |
| 396 | ;;; otherwise. It's not clear whether that's a bug | 372 | ;; otherwise. It's not clear whether that's a bug |
| 397 | ;;; or not (bug#51308). | 373 | ;; or not (bug#51308). |
| 398 | '(ert-fail signal))))) | 374 | '(ert-fail signal))))) |
| 399 | 375 | ||
| 400 | (ert-deftest ert-test-messages () | 376 | (ert-deftest ert-test-messages () |
| @@ -880,7 +856,6 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 880 | 856 | ||
| 881 | (ert-deftest ert-test-with-demoted-errors () | 857 | (ert-deftest ert-test-with-demoted-errors () |
| 882 | "Check that ERT correctly handles `with-demoted-errors'." | 858 | "Check that ERT correctly handles `with-demoted-errors'." |
| 883 | :expected-result :failed ;; FIXME! Bug#11218 | ||
| 884 | (should-not (with-demoted-errors "FOO: %S" (error "Foo")))) | 859 | (should-not (with-demoted-errors "FOO: %S" (error "Foo")))) |
| 885 | 860 | ||
| 886 | (ert-deftest ert-test-fail-inside-should () | 861 | (ert-deftest ert-test-fail-inside-should () |