unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Gemini Lasswell <gazally@runbox.com>
Cc: 25158-done@debbugs.gnu.org, michael.albinus@gmx.de
Subject: bug#25158: [PATCH] A better way for test code to access messages
Date: Sat, 04 Feb 2017 13:39:53 +0200	[thread overview]
Message-ID: <83fuju89rq.fsf@gnu.org> (raw)
In-Reply-To: <m2d1gzr8v2.fsf@rainbow.local> (message from Gemini Lasswell on Sat, 10 Dec 2016 09:29:05 -0800)

> Cc: Eli Zaretskii <eliz@gnu.org>, Michael Albinus <michael.albinus@gmx.de>
> From: Gemini Lasswell <gazally@runbox.com>
> 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 <eliz@gnu.org> 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
> there.

Making these changes didn't introduce any regressions in the relevant
tests, so I pushed them.

Gemini, please consider documenting the new macro in the ERT manual
and in NEWS.

Thanks.





  parent reply	other threads:[~2017-02-04 11:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-10 17:29 bug#25158: [PATCH] A better way for test code to access messages Gemini Lasswell
2016-12-10 19:27 ` Michael Albinus
2017-02-04 11:39 ` Eli Zaretskii [this message]
2017-02-05 13:12   ` Michael Albinus
2017-02-07 20:46     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fuju89rq.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=25158-done@debbugs.gnu.org \
    --cc=gazally@runbox.com \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).