[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25158: [PATCH] A better way for test code to access messages

From: Gemini Lasswell
Subject: bug#25158: [PATCH] A better way for test code to access messages
Date: Sat, 10 Dec 2016 09:29:05 -0800

Here is a quote from Bug#24939's discussion, regarding the technique
used by autorevert-tests.el, filenotify-tests.el and the proposed
kmacro-tests.el to collect messages issued during part of a test by
temporarily narrowing *Messages*:

Eli Zaretskii <address@hidden> writes:

> I don't like this implementation.  First, playing restriction games
> with *Messages* is inherently unsafe, because that buffer is treated
> specially by the code which puts messages there.  Second, this assumes
> *Messages* will have each message verbatim, which is false, because
> repeated messages aren't inserted.  And finally, some code can disable
> message logging or use some mechanism for displaying echo-area
> messages that bypasses *Messages*, in which case this macro will not
> catch the message.
> So I'd suggest instead to override or advice 'message', so you could
> get your hands on the messages more reliably.  It is possible we
> should have a more thorough infrastructure for collecting echo-area
> messages, which probably means parts of it should be implemented in C,
> but that's a separate project.

The attached patch adds a new macro called ert-with-message-capture to
ert-x.el which temporarily adds advice to 'message' to collect messages.
I've also modified autorevert-tests.el and filenotify-tests.el to use
the new macro. If or when the more thorough infrastructure is
implemented, that could replace the use of advice in this macro but the
tests which use it should not have to change.

Michael, in modifying autorevert-tests.el, at the start of
auto-revert-test02-auto-revert-deleted-file, *Messages* was narrowed,
and then narrowed again before the call to auto-revert--wait-for-revert,
so it looked safe to delete the first narrowing instead of replacing it
with ert-with-message-capture. Let me know if I've missed something

Attachment: 0001-Add-ert-with-message-capture.patch
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]