[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 25ea99c211e 04/14: Fix ert-tests.el for the new `handler-bind` co
From: |
Stefan Monnier |
Subject: |
master 25ea99c211e 04/14: Fix ert-tests.el for the new `handler-bind` code |
Date: |
Thu, 4 Jan 2024 18:55:32 -0500 (EST) |
branch: master
commit 25ea99c211ecf91735b44172da19fc53b304c5f4
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
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!
---
test/lisp/emacs-lisp/ert-tests.el | 41 ++++++++-------------------------------
1 file 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 @@
;;; ert-tests.el --- ERT's self-tests -*- lexical-binding: t -*-
-;; Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2024 Free Software Foundation, Inc.
;; Author: Christian Ohler <ohler@gnu.org>
@@ -93,16 +93,6 @@ failed or if there was a problem."
'(ert-test-failed "failure message"))
t))))
-(ert-deftest ert-test-fail-debug-with-condition-case ()
- (let ((test (make-ert-test :body (lambda () (ert-fail "failure message")))))
- (condition-case condition
- (progn
- (let ((ert-debug-on-error t))
- (ert-run-test test))
- (cl-assert nil))
- ((error)
- (cl-assert (equal condition '(ert-test-failed "failure message")) t)))))
-
(ert-deftest ert-test-fail-debug-with-debugger-1 ()
(let ((test (make-ert-test :body (lambda () (ert-fail "failure message")))))
(let ((debugger (lambda (&rest _args)
@@ -146,16 +136,6 @@ failed or if there was a problem."
'(error "Error message"))
t))))
-(ert-deftest ert-test-error-debug ()
- (let ((test (make-ert-test :body (lambda () (error "Error message")))))
- (condition-case condition
- (progn
- (let ((ert-debug-on-error t))
- (ert-run-test test))
- (cl-assert nil))
- ((error)
- (cl-assert (equal condition '(error "Error message")) t)))))
-
;;; Test that `should' works.
(ert-deftest ert-test-should ()
@@ -359,14 +339,10 @@ This macro is used to test if macroexpansion in `should'
works."
(,(lambda () (let ((_x t)) (should (error "Foo"))))
(error "Foo")))
do
- (let ((test (make-ert-test :body body)))
- (condition-case actual-condition
- (progn
- (let ((ert-debug-on-error t))
- (ert-run-test test))
- (cl-assert nil))
- ((error)
- (should (equal actual-condition expected-condition)))))))
+ (let* ((test (make-ert-test :body body))
+ (result (ert-run-test test)))
+ (should (ert-test-failed-p result))
+ (should (equal (ert-test-failed-condition result) expected-condition)))))
(defun ert-test--which-file ()
"Dummy function to help test `symbol-file' for tests.")
@@ -392,9 +368,9 @@ This macro is used to test if macroexpansion in `should'
works."
(result (ert-run-test test)))
(should (ert-test-failed-p result))
(should (memq (backtrace-frame-fun (car (ert-test-failed-backtrace
result)))
- ;;; This is `ert-fail' on nativecomp and `signal'
- ;;; otherwise. It's not clear whether that's a bug
- ;;; or not (bug#51308).
+ ;; This is `ert-fail' on nativecomp and `signal'
+ ;; otherwise. It's not clear whether that's a bug
+ ;; or not (bug#51308).
'(ert-fail signal)))))
(ert-deftest ert-test-messages ()
@@ -880,7 +856,6 @@ This macro is used to test if macroexpansion in `should'
works."
(ert-deftest ert-test-with-demoted-errors ()
"Check that ERT correctly handles `with-demoted-errors'."
- :expected-result :failed ;; FIXME! Bug#11218
(should-not (with-demoted-errors "FOO: %S" (error "Foo"))))
(ert-deftest ert-test-fail-inside-should ()
- master a5dcc1abea3 09/14: (macroexp--with-extended-form-stack): Use plain `let`, (continued)
- master a5dcc1abea3 09/14: (macroexp--with-extended-form-stack): Use plain `let`, Stefan Monnier, 2024/01/04
- master 391c208aecc 12/14: (backtrace-on-redisplay-error): Use `handler-bind`, Stefan Monnier, 2024/01/04
- master ae75333ca78 13/14: Improve `handler-bind` doc, Stefan Monnier, 2024/01/04
- master 5ba75e183c6 01/14: New special form `handler-bind`, Stefan Monnier, 2024/01/04
- master 7959a63ce25 02/14: (eval-expression): Fix bug#67196, Stefan Monnier, 2024/01/04
- master 2ef6e40da88 11/14: (signal_or_quit): Preserve error object identity, Stefan Monnier, 2024/01/04
- master 02edbc88a12 10/14: eval.c: Add new var `lisp-eval-depth-reserve`, Stefan Monnier, 2024/01/04
- master 604e34338f3 08/14: Move batch backtrace code to `top_level_2`, Stefan Monnier, 2024/01/04
- master 1081e975c93 14/14: Merge branch 'handler-bind', Stefan Monnier, 2024/01/04
- master fe0f15dbc96 03/14: ert.el: Use `handler-bind` to record backtraces, Stefan Monnier, 2024/01/04
- master 25ea99c211e 04/14: Fix ert-tests.el for the new `handler-bind` code,
Stefan Monnier <=