From 6d8b3d1077278b5c22652c796d3d878880cca1f3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 9 Mar 2026 22:40:31 -0400 Subject: [PATCH] test subdirectory: Use new error-API * test/lisp/vc/vc-tests/vc-tests.el (vc-test--run-maybe-unsupported-function): Remove dummy branch in `condition-case`. * test/lisp/arc-mode-tests.el (define-arc-mode-test-on-type): Use `error-slot-value`. * test/src/process-tests.el (process-tests--ignore-EMFILE): * test/src/filelock-tests.el (filelock-tests-unlock-spoiled) (filelock-tests-kill-buffer-spoiled): * test/lisp/vc/vc-git-tests.el (vc-git-test--run): * test/lisp/proced-tests.el (proced--assert-process-valid-cpu-refinement): * test/lisp/emacs-lisp/pp-tests.el (pp-tests--sanity): * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-with-normal-env) (edebug-tests-post-command): * test/lisp/autorevert-tests.el (auto-revert--deftest-remote): * test/infra/android/test-controller.el (ats-connect): --- test/infra/android/test-controller.el | 2 +- test/lisp/arc-mode-tests.el | 5 +++-- test/lisp/autorevert-tests.el | 2 +- test/lisp/emacs-lisp/edebug-tests.el | 5 ++--- test/lisp/emacs-lisp/pp-tests.el | 2 +- test/lisp/proced-tests.el | 2 +- test/lisp/vc/vc-git-tests.el | 2 +- test/lisp/vc/vc-tests/vc-tests.el | 3 +-- test/src/filelock-tests.el | 6 ++---- test/src/process-tests.el | 2 +- 10 files changed, 14 insertions(+), 17 deletions(-) diff --git a/test/infra/android/test-controller.el b/test/infra/android/test-controller.el index 07c6f0e5ba0..34a0e9bfe33 100644 --- a/test/infra/android/test-controller.el +++ b/test/infra/android/test-controller.el @@ -1910,7 +1910,7 @@ this machine and an SSH daemon be executing on the host)." (with-demoted-errors "Winding up failed connection: %S" (ats-adb "-s" device "forward" "--remove" (format "tcp:%d" host-port))) - (signal (car err) (cdr err)))))))))) + (signal err))))))))) diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index 43a441918a5..235a67c8649 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el @@ -113,9 +113,10 @@ member MEMBER. Then the test finds ARCHIVE and ensures that function ;; turn the most likely error into a nice ;; and self-explaining symbol that can be ;; compared in a `should' - (if (string= (cadr err) "Buffer format not recognized") + (if (equal (error-slot-value err 1) + "Buffer format not recognized") 'signature-not-recognized - (signal (car err) (cdr err)))))) + (signal err))))) (should (eq type (quote ,type))))) (when buffer (kill-buffer buffer)) (dolist (file (list member archive)) diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index 8a0ce146fbb..dfdfbafc5fa 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el @@ -203,7 +203,7 @@ It is checked for buffer-local `auto-revert-notify-watch-descriptor'." (tramp-dissect-file-name auto-revert--test-rootdir) t 'keep-password) (condition-case err (funcall (ert-test-body ert-test)) - (error (message "%s" err) (signal (car err) (cdr err))))))) + (error (message "%S" err) (signal err)))))) (defmacro with-auto-revert-test (&rest body) (declare (debug t)) diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el index c93dfad0a0d..61e909437c7 100644 --- a/test/lisp/emacs-lisp/edebug-tests.el +++ b/test/lisp/emacs-lisp/edebug-tests.el @@ -120,8 +120,7 @@ back to the top level.") (eval-buffer) ,@body (when edebug-tests-failure-in-post-command - (signal (car edebug-tests-failure-in-post-command) - (cdr edebug-tests-failure-in-post-command)))) + (signal edebug-tests-failure-in-post-command))) (unload-feature 'edebug-test-code) (with-current-buffer (find-file-noselect edebug-tests-temp-file) (set-buffer-modified-p nil)) @@ -246,7 +245,7 @@ keyboard macro." (funcall thunk) (error (setq edebug-tests-failure-in-post-command err) - (signal (car err) (cdr err))))) + (signal err)))) (setq edebug-tests-kbd-macro-index executing-kbd-macro-index)))) (defvar edebug-tests-func nil diff --git a/test/lisp/emacs-lisp/pp-tests.el b/test/lisp/emacs-lisp/pp-tests.el index ed4c9fcf978..c4e93e16005 100644 --- a/test/lisp/emacs-lisp/pp-tests.el +++ b/test/lisp/emacs-lisp/pp-tests.el @@ -82,7 +82,7 @@ (invalid-read-syntax (message "Invalid fill result with i=%d:\n%s" i (buffer-string)) - (signal (car err) (cdr err)) + (signal err) )))))))) (ert-deftest pp-tests--bug76715 () diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el index fce3c2bc048..52d1e8850ca 100644 --- a/test/lisp/proced-tests.el +++ b/test/lisp/proced-tests.el @@ -61,7 +61,7 @@ (proced--move-to-column "%CPU") (condition-case err (>= (proced--cpu-at-point) cpu) - (ert-test-skipped (signal (car err) (cdr err))) + (ert-test-skipped (signal err)) (error (ert-fail (list err (proced--assert-process-valid-cpu-refinement-explainer cpu)))))) diff --git a/test/lisp/vc/vc-git-tests.el b/test/lisp/vc/vc-git-tests.el index e93ee72210d..96fa3d65c05 100644 --- a/test/lisp/vc/vc-git-tests.el +++ b/test/lisp/vc/vc-git-tests.el @@ -111,7 +111,7 @@ If the exit status is non-zero, log the command output and re-throw." (apply 'vc-git-command t 0 nil args) (t (message "Error running Git: %s" err) (message "(buffer-string:\n%s\n)" (buffer-string)) - (signal (car err) (cdr err)))) + (signal err))) (buffer-string))) (defun vc-git-test--start-branch () diff --git a/test/lisp/vc/vc-tests/vc-tests.el b/test/lisp/vc/vc-tests/vc-tests.el index ca79a340a46..737ee09415e 100644 --- a/test/lisp/vc/vc-tests/vc-tests.el +++ b/test/lisp/vc/vc-tests/vc-tests.el @@ -238,8 +238,7 @@ For backends which don't support it, `vc-not-supported' is signaled." Catch the `vc-not-supported' error." `(condition-case err (funcall ,func ,@args) - (vc-not-supported 'vc-not-supported) - (t (signal (car err) (cdr err))))) + (vc-not-supported 'vc-not-supported))) (defun vc-test--register (backend) "Register and unregister a file. diff --git a/test/src/filelock-tests.el b/test/src/filelock-tests.el index 795039cd9cb..9284edd8b26 100644 --- a/test/src/filelock-tests.el +++ b/test/src/filelock-tests.el @@ -137,8 +137,7 @@ the case)." ;; Errors from `unlock-buffer' should call ;; `userlock--handle-unlock-error' (bug#46397). - (cl-letf (((symbol-function 'userlock--handle-unlock-error) - (lambda (err) (signal (car err) (cdr err))))) + (cl-letf (((symbol-function 'userlock--handle-unlock-error) #'signal)) (should (equal '(file-error "Unlocking file") (seq-subseq (should-error (unlock-buffer)) 0 2)))))) @@ -160,8 +159,7 @@ the case)." ;; File errors from unlocking files should call ;; `userlock--handle-unlock-error' (bug#46397). (cl-letf (((symbol-function 'yes-or-no-p) #'always) - ((symbol-function 'userlock--handle-unlock-error) - (lambda (err) (signal (car err) (cdr err))))) + ((symbol-function 'userlock--handle-unlock-error) #'signal)) (should (equal '(file-error "Unlocking file") (seq-subseq (should-error (kill-buffer)) 0 2)))))) diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 2cc5b37b187..55657a23fa9 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el @@ -546,7 +546,7 @@ See Bug#30460." ;; all `file-error' signals. (and ,message (not (string-equal (caddr ,err) ,message)) - (signal (car ,err) (cdr ,err)))))))) + (signal ,err))))))) (defmacro process-tests--with-buffers (var &rest body) "Bind VAR to nil and evaluate BODY.