From 55c60f025e834c6bc60523542644ac0ec03d035c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 21 Jun 2026 08:31:24 -0400 Subject: test: extract message-capture helper into testutil Five test files hand-rolled the same scaffolding to capture the echo-area message: a nil-initialized var, a cl-letf on message, and a lambda that stored the formatted string. Centralize it as testutil-wttrin-with-captured-message, which binds the var and captures the last message shown. Behavior is unchanged. The full suite stays green. Sites that mock message for a different reason are left alone: the ones that silence it with #'ignore, and the one that accumulates every message into a list. --- tests/test-wttrin-requery-force.el | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'tests/test-wttrin-requery-force.el') diff --git a/tests/test-wttrin-requery-force.el b/tests/test-wttrin-requery-force.el index d572348..171166d 100644 --- a/tests/test-wttrin-requery-force.el +++ b/tests/test-wttrin-requery-force.el @@ -63,15 +63,12 @@ "When no current location is set, user should be told there's nothing to refresh." (test-wttrin-requery-force-setup) (unwind-protect - (let ((displayed-message nil)) - (cl-letf (((symbol-function 'message) - (lambda (fmt &rest args) - (setq displayed-message (apply #'format fmt args))))) - (with-current-buffer (get-buffer-create "*wttr.in*") - ;; wttrin--current-location is nil (buffer-local default) - (wttrin-requery-force) - (should displayed-message) - (should (string-match-p "No location" displayed-message))))) + (testutil-wttrin-with-captured-message displayed-message + (with-current-buffer (get-buffer-create "*wttr.in*") + ;; wttrin--current-location is nil (buffer-local default) + (wttrin-requery-force) + (should displayed-message) + (should (string-match-p "No location" displayed-message)))) (test-wttrin-requery-force-teardown))) (ert-deftest test-wttrin-requery-force-boundary-force-flag-does-not-leak () -- cgit v1.2.3