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--display-weather.el | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'tests/test-wttrin--display-weather.el') diff --git a/tests/test-wttrin--display-weather.el b/tests/test-wttrin--display-weather.el index bca6a6c..4cc4269 100644 --- a/tests/test-wttrin--display-weather.el +++ b/tests/test-wttrin--display-weather.el @@ -159,11 +159,8 @@ Empty string does not match ERROR pattern, so it's processed as data." (test-wttrin--display-weather-setup) (unwind-protect (progn - (let ((message-log-max t) - (message-displayed nil)) - (cl-letf (((symbol-function 'message) - (lambda (format-string &rest args) - (setq message-displayed (apply #'format format-string args))))) + (let ((message-log-max t)) + (testutil-wttrin-with-captured-message message-displayed (wttrin--display-weather "InvalidCity" nil) ;; Should display error message @@ -176,11 +173,8 @@ Empty string does not match ERROR pattern, so it's processed as data." (test-wttrin--display-weather-setup) (unwind-protect (progn - (let ((message-log-max t) - (message-displayed nil)) - (cl-letf (((symbol-function 'message) - (lambda (format-string &rest args) - (setq message-displayed (apply #'format format-string args))))) + (let ((message-log-max t)) + (testutil-wttrin-with-captured-message message-displayed (wttrin--display-weather "BadLocation" testutil-wttrin-sample-error-response) ;; Should display error message -- cgit v1.2.3