From 64dd3f2a7a35317cbd9e8829c7b7fe259c797815 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 10:51:01 -0500 Subject: test: catch cl-assertion-failed by name without ERT should-wrapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix wrapped condition-case in (should (eq 'caught ...)), but ERT in Emacs 29.4 installs signal-hook-function around should forms — that hook fires on every signal, intercepting them before the inner condition-case can catch. CI on 29.4 still failed. This iteration drops should entirely. Each test body becomes a plain condition-case at the top level: run the form, and if it returns normally, ert-fail. Catch cl-assertion-failed by name rather than via the error parent — its parent-class registration is inconsistent across Emacs versions, but the symbol-name match through condition-case always works. Locally green; let's see what 29.4 does with it. --- ...st-org-drill-determine-next-interval-simple8.el | 28 ++++++++++++---------- .../test-org-drill-determine-next-interval-sm5.el | 16 ++++++------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/test-org-drill-determine-next-interval-simple8.el b/tests/test-org-drill-determine-next-interval-simple8.el index e9b43c3..667894a 100644 --- a/tests/test-org-drill-determine-next-interval-simple8.el +++ b/tests/test-org-drill-determine-next-interval-simple8.el @@ -206,18 +206,22 @@ review attempt regardless of which scheduling algorithm produced it." ;;; Error Cases - cl-assert violations (defmacro test-scheduler--should-cl-assert (&rest body) - "Assert BODY signals a cl-assert violation, catching via condition-case. - -The plain `should-error' macro is fragile across Emacs versions for -cl-assert-based tests — Emacs 29.4 in CI marks them as failures even -when the cl-assertion-failed signal fires (visible in the -test-failure backtrace). A manual condition-case sidesteps the -fragility: we just verify SOMETHING was signalled." - `(should - (eq 'caught - (condition-case nil - (progn ,@body 'no-error) - (error 'caught))))) + "Assert BODY signals a cl-assertion-failed via condition-case. + +Avoids `should-error' (and `should' generally) because ERT in Emacs +29.4 installs `signal-hook-function' around `should' forms — that +hook intercepts signals before any inner condition-case can catch +them, so the plain (should-error ...) wrap fails on 29.4 even +though the cl-assertion-failed signal does fire. + +Catches `cl-assertion-failed' by name rather than via the generic +`error' parent: the parent inheritance for cl-assertion-failed is +inconsistent across Emacs versions, but the symbol-name match +through condition-case always works." + `(condition-case _err + (progn ,@body + (ert-fail "expected cl-assertion-failed signal, got none")) + (cl-assertion-failed nil))) (ert-deftest test-org-drill-determine-next-interval-simple8-error-negative-repeats () "Error: repeats=-1 violates the (cl-assert (>= repeats 0)) precondition." diff --git a/tests/test-org-drill-determine-next-interval-sm5.el b/tests/test-org-drill-determine-next-interval-sm5.el index 126760a..e0ac464 100644 --- a/tests/test-org-drill-determine-next-interval-sm5.el +++ b/tests/test-org-drill-determine-next-interval-sm5.el @@ -245,14 +245,14 @@ The SM5 floor is shared with SM2 via `org-drill-modify-e-factor'.") ;;; Error Cases - cl-assert violations (defmacro test-scheduler--should-cl-assert (&rest body) - "Assert BODY signals a cl-assert violation, catching via condition-case. - -Mirrors the simple8 test file's helper. See its commentary." - `(should - (eq 'caught - (condition-case nil - (progn ,@body 'no-error) - (error 'caught))))) + "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))) (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