From unknown Tue Aug 12 07:34:06 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25158 <25158@debbugs.gnu.org> To: bug#25158 <25158@debbugs.gnu.org> Subject: Status: [PATCH] A better way for test code to access messages Reply-To: bug#25158 <25158@debbugs.gnu.org> Date: Tue, 12 Aug 2025 14:34:06 +0000 retitle 25158 [PATCH] A better way for test code to access messages reassign 25158 emacs submitter 25158 Gemini Lasswell severity 25158 normal tag 25158 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 12:29:39 2016 Received: (at submit) by debbugs.gnu.org; 10 Dec 2016 17:29:39 +0000 Received: from localhost ([127.0.0.1]:37168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFlSs-0004D0-GC for submit@debbugs.gnu.org; Sat, 10 Dec 2016 12:29:39 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59407) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFlSq-0004Cl-1d for submit@debbugs.gnu.org; Sat, 10 Dec 2016 12:29:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cFlSi-00042l-Hq for submit@debbugs.gnu.org; Sat, 10 Dec 2016 12:29:30 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cFlSi-00042h-EO for submit@debbugs.gnu.org; Sat, 10 Dec 2016 12:29:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cFlSf-0003WN-9T for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2016 12:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cFlSc-0003zB-33 for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2016 12:29:25 -0500 Received: from aibo.runbox.com ([91.220.196.211]:52180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cFlSb-0003xY-Hn for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2016 12:29:22 -0500 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cFlSY-0001bb-Sb for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2016 18:29:18 +0100 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=rainbow.local) by mailfront11.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1cFlSN-0004vR-Pa for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2016 18:29:08 +0100 From: Gemini Lasswell To: bug-gnu-emacs@gnu.org Subject: [PATCH] A better way for test code to access messages X-Debbugs-CC: Eli Zaretskii , Michael Albinus Date: Sat, 10 Dec 2016 09:29:05 -0800 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Add-ert-with-message-capture.patch >From da4bfb3adbb97841a3bf8bd80dfee7e6a474be32 Mon Sep 17 00:00:00 2001 From: gazally Date: Wed, 30 Nov 2016 12:12:53 -0800 Subject: [PATCH] Add ert-with-message-capture * lisp/emacs-lisp/ert-x.el (ert-with-message-capture): New function. * test/lisp/autorevert-tests.el (auto-revert--wait-for-revert) (auto-revert-test00-auto-revert-mode) (auto-revert-test01-auto-revert-several-files) (auto-revert-test02-auto-revert-deleted-file) (auto-revert-test03-auto-revert-tail-mode) (auto-revert-test04-auto-revert-mode-dired): Use it. * test/lisp/filenotify-tests.el (file-notify-test03-autorevert): Use it. --- lisp/emacs-lisp/ert-x.el | 24 ++++++ test/lisp/autorevert-tests.el | 166 +++++++++++++++++++----------------------- test/lisp/filenotify-tests.el | 56 +++++++------- 3 files changed, 125 insertions(+), 121 deletions(-) diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 2a2418f..42899b3 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -285,6 +285,30 @@ ert-buffer-string-reindented (kill-buffer clone))))))) +(defmacro ert-with-message-capture (var &rest body) + "Execute BODY while collecting anything written with `message' in VAR. + +Capture all messages produced by `message' when it is called from +Lisp, and concatenate them separated by newlines into one string. + +This is useful for separating the issuance of messages by the +code under test from the behavior of the *Messages* buffer." + (declare (debug (symbolp body)) + (indent 1)) + (let ((g-advice (cl-gensym))) + `(let* ((,var "") + (,g-advice (lambda (func &rest args) + (if (or (null args) (equal (car args) "")) + (apply func args) + (let ((msg (apply #'format-message args))) + (setq ,var (concat ,var msg "\n")) + (funcall func "%s" msg)))))) + (advice-add 'message :around ,g-advice) + (unwind-protect + (progn ,@body) + (advice-remove 'message ,g-advice))))) + + (provide 'ert-x) ;;; ert-x.el ends here diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index 2f951c0..4dbeec5 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el @@ -24,24 +24,29 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'autorevert) (setq auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded" auto-revert-stop-on-user-input nil) (defconst auto-revert--timeout 10 - "Time to wait until a message appears in the *Messages* buffer.") + "Time to wait for a message.") + +(defvar auto-revert--messages nil + "Used to collect messages issued during a section of a test.") (defun auto-revert--wait-for-revert (buffer) - "Wait until the *Messages* buffer reports reversion of BUFFER." + "Wait until a message reports reversion of BUFFER. +This expects `auto-revert--messages' to be bound by +`ert-with-message-capture' before calling." (with-timeout (auto-revert--timeout nil) - (with-current-buffer "*Messages*" - (while - (null (string-match - (format-message "Reverting buffer `%s'." (buffer-name buffer)) - (buffer-string))) - (if (with-current-buffer buffer auto-revert-use-notify) - (read-event nil nil 0.1) - (sleep-for 0.1)))))) + (while + (null (string-match + (format-message "Reverting buffer `%s'." (buffer-name buffer)) + auto-revert--messages)) + (if (with-current-buffer buffer auto-revert-use-notify) + (read-event nil nil 0.1) + (sleep-for 0.1))))) (ert-deftest auto-revert-test00-auto-revert-mode () "Check autorevert for a file." @@ -51,41 +56,38 @@ auto-revert--wait-for-revert buf) (unwind-protect (progn - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (write-region "any text" nil tmpfile nil 'no-message) + (write-region "any text" nil tmpfile nil 'no-message) (setq buf (find-file-noselect tmpfile)) - (with-current-buffer buf - (should (string-equal (buffer-string) "any text")) - ;; `buffer-stale--default-function' checks for - ;; `verify-visited-file-modtime'. We must ensure that it - ;; returns nil. - (sleep-for 1) - (auto-revert-mode 1) - (should auto-revert-mode) + (with-current-buffer buf + (ert-with-message-capture auto-revert--messages + (should (string-equal (buffer-string) "any text")) + ;; `buffer-stale--default-function' checks for + ;; `verify-visited-file-modtime'. We must ensure that it + ;; returns nil. + (sleep-for 1) + (auto-revert-mode 1) + (should auto-revert-mode) - ;; Modify file. We wait for a second, in order to have - ;; another timestamp. - (sleep-for 1) - (write-region "another text" nil tmpfile nil 'no-message) + ;; Modify file. We wait for a second, in order to have + ;; another timestamp. + (sleep-for 1) + (write-region "another text" nil tmpfile nil 'no-message) - ;; Check, that the buffer has been reverted. - (auto-revert--wait-for-revert buf) + ;; Check, that the buffer has been reverted. + (auto-revert--wait-for-revert buf)) (should (string-match "another text" (buffer-string))) ;; When the buffer is modified, it shall not be reverted. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (set-buffer-modified-p t) - (sleep-for 1) - (write-region "any text" nil tmpfile nil 'no-message) + (ert-with-message-capture auto-revert--messages + (set-buffer-modified-p t) + (sleep-for 1) + (write-region "any text" nil tmpfile nil 'no-message) - ;; Check, that the buffer hasn't been reverted. - (auto-revert--wait-for-revert buf) + ;; Check, that the buffer hasn't been reverted. + (auto-revert--wait-for-revert buf)) (should-not (string-match "any text" (buffer-string))))) ;; Exit. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (with-current-buffer buf (set-buffer-modified-p nil)) (kill-buffer buf)) @@ -106,13 +108,11 @@ auto-revert--wait-for-revert (make-temp-file (expand-file-name "auto-revert-test" tmpdir1))) buf1 buf2) (unwind-protect - (progn - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (write-region "any text" nil tmpfile1 nil 'no-message) - (setq buf1 (find-file-noselect tmpfile1)) - (write-region "any text" nil tmpfile2 nil 'no-message) - (setq buf2 (find-file-noselect tmpfile2)) + (ert-with-message-capture auto-revert--messages + (write-region "any text" nil tmpfile1 nil 'no-message) + (setq buf1 (find-file-noselect tmpfile1)) + (write-region "any text" nil tmpfile2 nil 'no-message) + (setq buf2 (find-file-noselect tmpfile2)) (dolist (buf (list buf1 buf2)) (with-current-buffer buf @@ -148,7 +148,6 @@ auto-revert--wait-for-revert (should (string-match "another text" (buffer-string)))))) ;; Exit. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (dolist (buf (list buf1 buf2)) (with-current-buffer buf (set-buffer-modified-p nil)) @@ -165,8 +164,6 @@ auto-revert--wait-for-revert buf) (unwind-protect (progn - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) (write-region "any text" nil tmpfile nil 'no-message) (setq buf (find-file-noselect tmpfile)) (with-current-buffer buf @@ -184,42 +181,36 @@ auto-revert--wait-for-revert 'before-revert-hook (lambda () (delete-file buffer-file-name)) nil t) - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 1) - (write-region "another text" nil tmpfile nil 'no-message) - ;; Check, that the buffer hasn't been reverted. File - ;; notification should be disabled, falling back to - ;; polling. - (auto-revert--wait-for-revert buf) + (ert-with-message-capture auto-revert--messages + (sleep-for 1) + (write-region "another text" nil tmpfile nil 'no-message) + (auto-revert--wait-for-revert buf)) + ;; Check, that the buffer hasn't been reverted. File + ;; notification should be disabled, falling back to + ;; polling. (should (string-match "any text" (buffer-string))) (should-not auto-revert-use-notify) ;; Once the file has been recreated, the buffer shall be ;; reverted. (kill-local-variable 'before-revert-hook) - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 1) - (write-region "another text" nil tmpfile nil 'no-message) - - ;; Check, that the buffer has been reverted. - (auto-revert--wait-for-revert buf) + (ert-with-message-capture auto-revert--messages + (sleep-for 1) + (write-region "another text" nil tmpfile nil 'no-message) + (auto-revert--wait-for-revert buf)) + ;; Check, that the buffer has been reverted. (should (string-match "another text" (buffer-string))) ;; An empty file shall still be reverted. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 1) - (write-region "" nil tmpfile nil 'no-message) - - ;; Check, that the buffer has been reverted. - (auto-revert--wait-for-revert buf) + (ert-with-message-capture auto-revert--messages + (sleep-for 1) + (write-region "" nil tmpfile nil 'no-message) + (auto-revert--wait-for-revert buf)) + ;; Check, that the buffer has been reverted. (should (string-equal "" (buffer-string))))) ;; Exit. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (with-current-buffer buf (set-buffer-modified-p nil)) (kill-buffer buf)) @@ -232,9 +223,7 @@ auto-revert--wait-for-revert (let ((tmpfile (make-temp-file "auto-revert-test")) buf) (unwind-protect - (progn - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) + (ert-with-message-capture auto-revert--messages (write-region "any text" nil tmpfile nil 'no-message) (setq buf (find-file-noselect tmpfile)) (with-current-buffer buf @@ -259,7 +248,6 @@ auto-revert--wait-for-revert (string-match "modified text\nanother text" (buffer-string))))) ;; Exit. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (kill-buffer buf)) (ignore-errors (delete-file tmpfile))))) @@ -283,33 +271,29 @@ auto-revert--wait-for-revert (should (string-match name (substring-no-properties (buffer-string)))) - ;; Delete file. We wait for a second, in order to have - ;; another timestamp. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 1) - (delete-file tmpfile) - - ;; Check, that the buffer has been reverted. - (auto-revert--wait-for-revert buf) + (ert-with-message-capture auto-revert--messages + ;; Delete file. We wait for a second, in order to have + ;; another timestamp. + (sleep-for 1) + (delete-file tmpfile) + (auto-revert--wait-for-revert buf)) + ;; Check, that the buffer has been reverted. (should-not (string-match name (substring-no-properties (buffer-string)))) - ;; Make dired buffer modified. Check, that the buffer has - ;; been still reverted. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (set-buffer-modified-p t) - (sleep-for 1) - (write-region "any text" nil tmpfile nil 'no-message) + (ert-with-message-capture auto-revert--messages + ;; Make dired buffer modified. Check, that the buffer has + ;; been still reverted. + (set-buffer-modified-p t) + (sleep-for 1) + (write-region "any text" nil tmpfile nil 'no-message) - ;; Check, that the buffer has been reverted. - (auto-revert--wait-for-revert buf) + (auto-revert--wait-for-revert buf)) + ;; Check, that the buffer has been reverted. (should (string-match name (substring-no-properties (buffer-string)))))) ;; Exit. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (with-current-buffer buf (set-buffer-modified-p nil)) (kill-buffer buf)) diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el index 0e6e58e..07a88ed 100644 --- a/test/lisp/filenotify-tests.el +++ b/test/lisp/filenotify-tests.el @@ -36,6 +36,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'filenotify) (require 'tramp) @@ -640,21 +641,19 @@ file-notify--test-with-events (should auto-revert-notify-watch-descriptor) ;; Modify file. We wait for a second, in order to have - ;; another timestamp. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 1) - (write-region - "another text" nil file-notify--test-tmpfile nil 'no-message) - - ;; Check, that the buffer has been reverted. - (with-current-buffer (get-buffer-create "*Messages*") - (file-notify--wait-for-events - timeout - (string-match + ;; another timestamp. + (ert-with-message-capture captured-messages + (sleep-for 1) + (write-region + "another text" nil file-notify--test-tmpfile nil 'no-message) + + ;; Check, that the buffer has been reverted. + (file-notify--wait-for-events + timeout + (string-match (format-message "Reverting buffer `%s'." (buffer-name buf)) - (buffer-string)))) - (should (string-match "another text" (buffer-string))) + captured-messages)) + (should (string-match "another text" (buffer-string)))) ;; Stop file notification. Autorevert shall still work via polling. (file-notify-rm-watch auto-revert-notify-watch-descriptor) @@ -665,27 +664,24 @@ file-notify--test-with-events ;; Modify file. We wait for two seconds, in order to ;; have another timestamp. One second seems to be too - ;; short. - (with-current-buffer (get-buffer-create "*Messages*") - (narrow-to-region (point-max) (point-max))) - (sleep-for 2) - (write-region - "foo bla" nil file-notify--test-tmpfile nil 'no-message) - - ;; Check, that the buffer has been reverted. - (with-current-buffer (get-buffer-create "*Messages*") - (file-notify--wait-for-events - timeout - (string-match - (format-message "Reverting buffer `%s'." (buffer-name buf)) - (buffer-string)))) - (should (string-match "foo bla" (buffer-string)))) + ;; short. + (ert-with-message-capture captured-messages + (sleep-for 2) + (write-region + "foo bla" nil file-notify--test-tmpfile nil 'no-message) + + ;; Check, that the buffer has been reverted. + (file-notify--wait-for-events + timeout + (string-match + (format-message "Reverting buffer `%s'." (buffer-name buf)) + captured-messages)) + (should (string-match "foo bla" (buffer-string))))) ;; The environment shall be cleaned up. (file-notify--test-cleanup-p)) ;; Cleanup. - (with-current-buffer "*Messages*" (widen)) (ignore-errors (kill-buffer buf)) (file-notify--test-cleanup)))) -- 2.10.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 14:27:51 2016 Received: (at 25158) by debbugs.gnu.org; 10 Dec 2016 19:27:51 +0000 Received: from localhost ([127.0.0.1]:37255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFnJH-0007HT-5J for submit@debbugs.gnu.org; Sat, 10 Dec 2016 14:27:51 -0500 Received: from mout.gmx.net ([212.227.17.21]:64104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFnJE-0007HC-N2 for 25158@debbugs.gnu.org; Sat, 10 Dec 2016 14:27:49 -0500 Received: from detlef.gmx.de ([87.146.49.139]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0McUnM-1by7vo2uA4-00Hgjp; Sat, 10 Dec 2016 20:27:40 +0100 From: Michael Albinus To: Gemini Lasswell Subject: Re: bug#25158: [PATCH] A better way for test code to access messages References: Date: Sat, 10 Dec 2016 20:27:38 +0100 In-Reply-To: (Gemini Lasswell's message of "Sat, 10 Dec 2016 09:29:05 -0800") Message-ID: <87inqrlh3p.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:OcTgSheSCUaR5GDAkr15iLciv7SsjpGRTdCXDI8dJccoS5iC+uE oZ0gGnlTzu8dTW3u7+aT9t8qQdy5ZTqRPSP4FhvIaXWENYTup8gXJHVjgtAZI73XgR+al+o ANHK7kn5smG6txztVfeCiNU41+1y3SQkvcUKu6e5mFwSmDojXs/g/GDYmJUbkNRuGM4SXaa DOLUgE0pMznnGdTTYU2fQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:1Rwi5S64P0k=:rTQRf+UVnmie0yEcDxQ/h3 yci58WzobGAA4B5oEYkM5pTOpRElF6I78llSl6NzZSeLdIYvEAkZAD6ncdU0IV8Fg7miEHKqb kAs8L/CKe4MhzEhkwx++ytKOGyyGPjVmVnt2le7ipi4wy6aW4kMkTkagFQaQidSC6FX+T409w Z8Ei1ZUeVS8XbKMwZWiefZzDSyisGcsPRbBECfN8aWyJmVSuktMO90cCWFEd0JBMgYT2y0gpE 7Q3PsevO3g2p0Y58KDuNH3grZ46avfv1175jqUisDihaFhL4sXHFYbkvMXuRdP2tLgryxqbfC uXQTAg7dkI7UxYvWD4EQxHGmOLp/NEZLIdotTteor1x4I4ui6UqnJ5sc9ItKwJDsZW10gDPnH y9iTN3H3W47jbA7gbDkfMnzQ5HM16kXZYHayVM8on7mXGBbz4WkezRtxSGc2LiX+V39nzJKaS HIVuA7KeHqAE205t5MyyPDUXFAfTtnv5tDxRTIf0s6p72gqy1XF6cKS/61KGe4j2Q2iufvBEK fLIL3e4G5WyjEBOiRZQyKOSwZtD0ugaBAp4X7KPm/9vN+w/vXwPYLIfqk0TnhHEdzfATu1ter B2uIg5UMHtf+KLH0Wcpj2RVciKEkQNZf7yQ13d/Dzc8XqROS+PozmCjhcLG0a7/iLA9e5W+UK Xq4iYDjLBbEyJaNxhvPsT1OzVV7ab73D/w5czTImMC83aEvop48lzh839OFSECUlMz7E4tEns OmLiwNYOebhceabH2AyaDKkepqrPQIOkdz4UZ9eusblQFIp1TfbscCm1MeYYxli2nR+dTnhq0 xLbbRQf X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 25158 Cc: 25158@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Gemini Lasswell writes: > 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. In autorevert-tests.el, the *Messages* buffer is narrowed systematically prior any write-region call. I don't remember the details, but AFAIR there were some other messages which have poisoned the tests. I let it to you to change wherever you feel it is necessary. Tests will show whether there are undesired side effects. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 06:40:16 2017 Received: (at 25158-done) by debbugs.gnu.org; 4 Feb 2017 11:40:17 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 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 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 Date: Sat, 04 Feb 2017 13:39:53 +0200 Message-Id: <83fuju89rq.fsf@gnu.org> From: Eli Zaretskii To: Gemini Lasswell In-reply-to: (message from Gemini Lasswell on Sat, 10 Dec 2016 09:29:05 -0800) Subject: Re: bug#25158: [PATCH] A better way for test code to access messages References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 25158-done Cc: 25158-done@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 08:12:31 2017 Received: (at 25158-done) by debbugs.gnu.org; 5 Feb 2017 13:12:31 +0000 Received: from localhost ([127.0.0.1]:56535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1caMcJ-0001Nb-Ij for submit@debbugs.gnu.org; Sun, 05 Feb 2017 08:12:31 -0500 Received: from mout.gmx.net ([212.227.15.15]:51207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1caMcG-0001NK-UM for 25158-done@debbugs.gnu.org; Sun, 05 Feb 2017 08:12:29 -0500 Received: from detlef.gmx.de ([62.227.222.33]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MJjOu-1cZG9X3o9c-001DEM; Sun, 05 Feb 2017 14:12:20 +0100 From: Michael Albinus To: Eli Zaretskii Subject: Re: bug#25158: [PATCH] A better way for test code to access messages References: <83fuju89rq.fsf@gnu.org> Date: Sun, 05 Feb 2017 14:12:17 +0100 Message-ID: <87shns7pe6.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:i2Pizpm4f1rgP6Tn2YGb9TbeBHbuW/ZVgT6kUH5SNuM2Bi39v5S dWuvc0vlQz3T80tYwHzqNfdQSuQKiHtXVAwGsylykBmYY/n+D/kq6i1CkHiNgusK/jrlJMF +r+lfSTqhlp/9P35GIHSL3pUn3VOi0RTEdQKbQGxcpiZW+gIzTY8e8o3pAE3iufNHLmA4qN lDcYQMFGzzBeNbzXk1zeA== X-UI-Out-Filterresults: notjunk:1;V01:K0:nlVG32dMJvk=:6h0+/Ga8631K8z9i0xGXhR vvZe4dfgkJumMp41037PGo59Xb7Gf6/IgDpdS8x94np5D+rUX7hUF0z5B1vS+cw6KbZia2lOz Ka3ExQYHZHLKoSgjYIMwAuZHCrXr8p7LPLPoCizUz7rBGdt94Xidy4MM09YQ/M/9EKxtqOep9 iQTWrqv9Mp2ijxu4OcOtzmlfT25gQlaR9IM5UPzr7TFwcsfMPGgQo0F/iFhgoQ8ocJNn9mFyf O83paEBDFuHj4N/z7wZfVoTeD9tDWtwSBbrVPXod2dMww0CSRh54QpUQix+W+E4JTzZ8z2WiH AxeEFQBtAi/sh+yqyZIznZQu7tIVRS1NK9iyVHhHfR9uGx/qR4Cjel+1Ov+f0kOLfnbwph6+d 1r68ilCR/jhAwhCq1qqgNmAs5YeN2K8+Ctgm8aHKjrAAkiMz6zQX4yRljlPdm6VeirIZrHqw6 jIPn9pjJjxL1EftZ9rexmDJOfKGPPtRJb80wWm4lUXzUXOzSki3ij7+oP9qLFyuxzNgmfnI8s 9RWCrpss4dL1UfPpHr2vz7GPgMNCkEq0xc6AFaJj/Oq1qEMtzPODMLyPX+Zyk+Fy0WRw+LSJV R8qK5JH87PqdjUYJQdHbam3/53XOYEZvnq9y24oKVGaBNW1zL3w147RwJ4Ap1Y4WjWCkwRKc/ akYM5rM9wuzT49+7iHUQJDvWTHeAOf2/ro1tic4yeJUdU/2RJpLS+vrFAGawgvYTwIv8fqVuv s5BhwkJjuAbVAJEkZknKq8L4H7VWesc1UYR6zwwCD/llgeaSttL6FwMdfB9JTnNH28GQJz4ii eAel2CZ X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 25158-done Cc: 25158-done@debbugs.gnu.org, Gemini Lasswell X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Eli Zaretskii writes: > Making these changes didn't introduce any regressions in the relevant > tests, so I pushed them. There is a new error when running under GNU/Linux from a shell: --8<---------------cut here---------------start------------->8--- # make SELECTOR=\'file-notify-test03-autorevert-remote -C test filenotify-tests [...] Testing lisp/filenotify-tests.el Running 1 tests (2017-02-05 11:42:33+0100) Reverting buffer `file-notify-test141896xu'. Error: (wrong-type-argument stringp nil) Reverting buffer `file-notify-test141896xu'. Error: (wrong-type-argument stringp nil) passed 1/1 file-notify-test03-autorevert-remote --8<---------------cut here---------------end--------------->8--- The test passes, but the error message looks suspicious. I've tried to find where it comes from, and it seems to be the new macro `ert-with-message-capture'. I didn't debug further; maybe Gemini could have a look? The bug is not visible when running the test interactively. > Thanks. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 07 15:47:08 2017 Received: (at 25158-done) by debbugs.gnu.org; 7 Feb 2017 20:47:08 +0000 Received: from localhost ([127.0.0.1]:59332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbCfM-0002lC-IW for submit@debbugs.gnu.org; Tue, 07 Feb 2017 15:47:08 -0500 Received: from mout.gmx.net ([212.227.15.15]:62466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbCfL-0002ki-Jg for 25158-done@debbugs.gnu.org; Tue, 07 Feb 2017 15:47:08 -0500 Received: from detlef.gmx.de ([93.197.210.63]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MK0Np-1ccaF52Whh-001UCu; Tue, 07 Feb 2017 21:46:58 +0100 From: Michael Albinus To: Eli Zaretskii Subject: Re: bug#25158: [PATCH] A better way for test code to access messages References: <83fuju89rq.fsf@gnu.org> <87shns7pe6.fsf@gmx.de> Date: Tue, 07 Feb 2017 21:46:57 +0100 In-Reply-To: <87shns7pe6.fsf@gmx.de> (Michael Albinus's message of "Sun, 05 Feb 2017 14:12:17 +0100") Message-ID: <87vasl91a6.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:sU1r9brbdPrbLYsjKhEtBZfxte/BOHjxSf2mdBQYEpRFVDUsrhK SKMEJT3OH5YY48xD+fGxylaCcq605EpXJ4TIAsCaW/LQzenTFA1Dm3Pf63KVPxNeVVLWZix deE0RKkv+PuiuyWuyIplRX10D0oxPoIZMvThLWd1Iq+drX2GiFi5Hzxt+V+bpYvNmjl/A8l Qo35zQPtk2BX5755l/xhQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:/8TPmH9++zU=:rYUHKjBEYTy8jjUB59MiJy lmDja2YdzHjIqU/3JiTqhdiZi3W6cgcz5W7lF7cFe3bqLEAFfrg/WrG+o6qC7HvKbcLhDneZY C9GmRV1CP7bgBV/LqPlHzJFSduoUMH09D+AyPpZgI9CN0f2aIaMIK5dX+LAfP9YgPFY9vGNXY eYSZG1q1+vV6WBjTndYFuEhOY51wgY7NKA3YVwZ7vtha2UZzhIhYy6GjbgXSAOSGKPE3YIhGD ymyrHZ55izWIDDRoQoGe7P0SG8MAVDIgJuWdII54NPtfVQmLDrZDKg44PeNaQsPLv/uQE1rZS ZkaR14JGkGHrijx3x9YIFoVBj7ET1D5cH8P4DI1+hp+CAxJ3/9abxgbfwC1kJOJjiA2aqrHgb 51AYN5IKkvCJehAySAuhzlT3S9NmeVd9EGfHtK5DgovzBYydAesJ/UDkrOBq4HeKpUgiYzeBv xrZz9ER1Bs65pL2QzcJpzpLydfyxSNSCNXjG0LTuRmx+l/arskBNdYC7VqQ5HKKSACyTqaY0t HR4B1jj8hoEBSNFNRMdiYWaVGY9kQczKbVWbOizEPLcz46f4UkDyuvzpbW70H8qN+59Kp9xkn cU7jX/APzrnCccExzTZZ4jGdR3Mifi0IVCWaJ6j3sA4Bx7u+S0bJoKXvKoreh4Lzfl3cmKsBu QqsMoKb2yvC0Jou3tPsIR/8bM3lE4k1BHyaTvzS3aWeDSxHwg+RogT3q3ZsTuzqLGiUte+EqM hFUkoXKoIq2bGVOBEPizJQoYdylJU5deuS2mpq5OKTzKGSMiLL+xgWs6uSdnmQCkvnzrVn237 SWStwaN X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 25158-done Cc: 25158-done@debbugs.gnu.org, Gemini Lasswell X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Michael Albinus writes: > Eli Zaretskii writes: > >> Making these changes didn't introduce any regressions in the relevant >> tests, so I pushed them. > > There is a new error when running under GNU/Linux from a shell: > > # make SELECTOR=\'file-notify-test03-autorevert-remote -C test filenotify-tests > [...] > Testing lisp/filenotify-tests.el > Running 1 tests (2017-02-05 11:42:33+0100) > > > Reverting buffer `file-notify-test141896xu'. > > Error: (wrong-type-argument stringp nil) > Reverting buffer `file-notify-test141896xu'. > > Error: (wrong-type-argument stringp nil) > passed 1/1 file-notify-test03-autorevert-remote > > The test passes, but the error message looks suspicious. I've tried to > find where it comes from, and it seems to be the new macro > `ert-with-message-capture'. I didn't debug further; maybe Gemini could > have a look? > > The bug is not visible when running the test interactively. Finally, it is not a bug of `ert-with-message-capture'. It comes from `vc-refresh-state', and it was not visible before using the new macro. I've adapted the test case `file-notify-test03-autorevert'; it works fine now. Bug#25158 could be closed. >> Thanks. Best regards, Michael. From unknown Tue Aug 12 07:34:06 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 08 Mar 2017 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator