From 01ad14ab75d5d64aadd15af8fc0d1dd61e2ce4bd Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 10:55:03 -0500 Subject: test: shadow signal-hook-function so cl-assertion-failed can be caught MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempt 4 at making the eight scheduler error tests pass on Emacs 29.4 in CI. The earlier approaches kept failing because ERT 29.4 installs ert--should-signal-hook as signal-hook-function around the entire ert-deftest body — not just inside should forms. That hook fires on every signal before any inner condition-case can catch it, which is why even a bare (condition-case ... (cl-assertion-failed nil)) at the top of the test body didn't work. The new helper rebinds signal-hook-function to nil inside its own let-scope, so condition-case catches the cl-assertion-failed signal normally. The ert-fail on the no-error path runs outside that shadowing scope, so it still routes through ERT's failure handling. Locally green; pushing to test 29.4 in CI. --- tests/test-org-drill-determine-next-interval-sm5.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/test-org-drill-determine-next-interval-sm5.el') diff --git a/tests/test-org-drill-determine-next-interval-sm5.el b/tests/test-org-drill-determine-next-interval-sm5.el index e0ac464..de476a4 100644 --- a/tests/test-org-drill-determine-next-interval-sm5.el +++ b/tests/test-org-drill-determine-next-interval-sm5.el @@ -248,11 +248,14 @@ The SM5 floor is shared with SM2 via `org-drill-modify-e-factor'.") "Assert BODY signals a cl-assertion-failed via condition-case. Mirrors the simple8 test file's helper. See its commentary for why -this avoids `should-error' / `should' on Emacs 29.4." - `(condition-case _err - (progn ,@body - (ert-fail "expected cl-assertion-failed signal, got none")) - (cl-assertion-failed nil))) +shadowing `signal-hook-function' is necessary on Emacs 29.4." + `(let ((caught + (let ((signal-hook-function nil)) + (condition-case _err + (progn ,@body 'no-error) + (cl-assertion-failed 'caught))))) + (unless (eq caught 'caught) + (ert-fail "expected cl-assertion-failed signal, got none")))) (ert-deftest test-org-drill-determine-next-interval-sm5-error-negative-n () "Error: n=-1 violates the (cl-assert (> n 0)) precondition." -- cgit v1.2.3