From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25158: [PATCH] A better way for test code to access messages Date: Sat, 04 Feb 2017 13:39:53 +0200 Message-ID: <83fuju89rq.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1486208480 11374 195.159.176.226 (4 Feb 2017 11:41:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Feb 2017 11:41:20 +0000 (UTC) Cc: 25158-done@debbugs.gnu.org, michael.albinus@gmx.de To: Gemini Lasswell Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 04 12:41:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZyiM-0002YB-PA for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 12:41:10 +0100 Original-Received: from localhost ([::1]:38847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZyiQ-0001pz-Fz for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 06:41:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZyiH-0001oi-T1 for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2017 06:41:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZyiE-0000AN-NB for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2017 06:41:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57353) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZyiE-0000AC-Ke for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2017 06:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cZyiE-0000LB-Ea for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2017 06:41:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Feb 2017 11:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 25158 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 25158@debbugs.gnu.org, eliz@gnu.org, gazally@runbox.com Original-Received: via spool by 25158-done@debbugs.gnu.org id=D25158.14862084171247 (code D ref 25158); Sat, 04 Feb 2017 11:41:02 +0000 Original-Received: (at 25158-done) by debbugs.gnu.org; 4 Feb 2017 11:40:17 +0000 Original-Received: from localhost ([127.0.0.1]:55551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZyhU-0000K3-LG for submit@debbugs.gnu.org; Sat, 04 Feb 2017 06:40:16 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZyhT-0000Jr-Em for 25158-done@debbugs.gnu.org; Sat, 04 Feb 2017 06:40:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZyhN-0008Lf-72 for 25158-done@debbugs.gnu.org; Sat, 04 Feb 2017 06:40:10 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZyhH-0008HG-8F; Sat, 04 Feb 2017 06:40:03 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1411 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cZyhG-0001UT-DJ; Sat, 04 Feb 2017 06:40:02 -0500 In-reply-to: (message from Gemini Lasswell on Sat, 10 Dec 2016 09:29:05 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:128946 Archived-At: > Cc: Eli Zaretskii , Michael Albinus > From: Gemini Lasswell > 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 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.