[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/handler-bind 1c1d2eb3e38 03/10: Use handler-bind to repair bytec
From: |
Stefan Monnier |
Subject: |
scratch/handler-bind 1c1d2eb3e38 03/10: Use handler-bind to repair bytecomp-tests |
Date: |
Thu, 28 Dec 2023 01:17:41 -0500 (EST) |
branch: scratch/handler-bind
commit 1c1d2eb3e389bb5e397cd8e1568e4e3129067912
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Use handler-bind to repair bytecomp-tests
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--error-frame, bytecomp--byte-op-error-backtrace):
Make test pass again and simplify, using handler-bind instead
of the previous debugger hack.
---
test/lisp/emacs-lisp/bytecomp-tests.el | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 8fbe48bbb9a..f4cefaaac92 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -2087,18 +2087,12 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode
js-mode python-mode)) \
(defun bytecomp-tests--error-frame (fun args)
"Call FUN with ARGS. Return result or (ERROR . BACKTRACE-FRAME)."
- (let* ((debugger
- (lambda (&rest args)
- ;; Make sure Emacs doesn't think our debugger is buggy.
- (cl-incf num-nonmacro-input-events)
- (throw 'bytecomp-tests--backtrace
- (cons args (cadr (backtrace-get-frames debugger))))))
- (debug-on-error t)
- (backtrace-on-error-noninteractive nil)
- (debug-on-quit t)
- (debug-ignored-errors nil))
+ (letrec ((handler (lambda (e)
+ (throw 'bytecomp-tests--backtrace
+ (cons e (cadr (backtrace-get-frames handler)))))))
(catch 'bytecomp-tests--backtrace
- (apply fun args))))
+ (handler-bind ((error handler))
+ (apply fun args)))))
(defconst bytecomp-tests--byte-op-error-cases
'(((car a) (wrong-type-argument listp a))
@@ -2143,7 +2137,7 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode
python-mode)) \
`(lambda ,formals (,fun-sym ,@formals)))))))
(error-frame (bytecomp-tests--error-frame fun actuals)))
(should (consp error-frame))
- (should (equal (car error-frame) (list 'error expected-error)))
+ (should (equal (car error-frame) expected-error))
(let ((frame (cdr error-frame)))
(should (equal (type-of frame) 'backtrace-frame))
(should (equal (cons (backtrace-frame-fun frame)
- branch scratch/handler-bind created (now 26b7078705a), Stefan Monnier, 2023/12/28
- scratch/handler-bind 89a298b3d2f 02/10: Fix ert-tests.el for the new `handler-bind` code, Stefan Monnier, 2023/12/28
- scratch/handler-bind dcf7508c947 04/10: emacs-module-tests.el (mod-test-non-local-exit-signal-test): Repair test, Stefan Monnier, 2023/12/28
- scratch/handler-bind 1c1d2eb3e38 03/10: Use handler-bind to repair bytecomp-tests,
Stefan Monnier <=
- scratch/handler-bind 6a57b9151b1 06/10: Move batch backtrace code to `top_level_2`, Stefan Monnier, 2023/12/28
- scratch/handler-bind ae21819496a 01/10: ert.el: Use `handler-bind` to record backtraces, Stefan Monnier, 2023/12/28
- scratch/handler-bind 26b7078705a 10/10: (backtrace-on-redisplay-error): Use `handler-bind`, Stefan Monnier, 2023/12/28
- scratch/handler-bind b925152bffc 09/10: (signal_or_quit): Preserve error object identity, Stefan Monnier, 2023/12/28
- scratch/handler-bind 917596160c1 05/10: startup.el: Use `handler-bind` to implement `--debug-init`, Stefan Monnier, 2023/12/28
- scratch/handler-bind 634bf619476 07/10: (macroexp--with-extended-form-stack): Use plain `let`, Stefan Monnier, 2023/12/28
- scratch/handler-bind c89b234405f 08/10: eval.c: Add new var `lisp-eval-depth-reserve`, Stefan Monnier, 2023/12/28