From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Gemini Lasswell Newsgroups: gmane.emacs.bugs Subject: bug#24939: [PATCH] Add tests for lisp/kmacro.el Date: Mon, 14 Nov 2016 10:26:42 -0800 Message-ID: References: <834m3ahxic.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1479148065 10902 195.159.176.226 (14 Nov 2016 18:27:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 14 Nov 2016 18:27:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (darwin) To: Eli Zaretskii , 24939@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 14 19:27:42 2016 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 1c6LyH-00071b-SP for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Nov 2016 19:27:09 +0100 Original-Received: from localhost ([::1]:41977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6LyL-0004Um-3H for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Nov 2016 13:27:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6LyE-0004UB-4V for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 13:27:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6LyA-0006r4-UC for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 13:27:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41951) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6LyA-0006qy-R1 for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 13:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c6LyA-0000RJ-GZ for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2016 13:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Nov 2016 18:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24939 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24939-submit@debbugs.gnu.org id=B24939.14791480151673 (code B ref 24939); Mon, 14 Nov 2016 18:27:02 +0000 Original-Received: (at 24939) by debbugs.gnu.org; 14 Nov 2016 18:26:55 +0000 Original-Received: from localhost ([127.0.0.1]:57350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6Ly2-0000Qv-Sz for submit@debbugs.gnu.org; Mon, 14 Nov 2016 13:26:55 -0500 Original-Received: from aibo.runbox.com ([91.220.196.211]:33725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6Ly1-0000Qn-Ln for 24939@debbugs.gnu.org; Mon, 14 Nov 2016 13:26:54 -0500 Original-Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1c6Lxz-0003vz-MF; Mon, 14 Nov 2016 19:26:51 +0100 Original-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 1c6Lxt-00070Y-9E; Mon, 14 Nov 2016 19:26:45 +0100 In-Reply-To: <834m3ahxic.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 14 Nov 2016 17:49:47 +0200") 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:125697 Archived-At: Thanks for the thorough feedback! I'll work on a new & improved version incorporating your comments. Some responses/questions below. >> +(defmacro kmacro-tests-should-match-message (value &rest body) >> + "Verify that a message matching VALUE is issued while executing BODY. >> +Execute BODY, then check for a regexp match between >> +VALUE and any text written to *Messages* during the execution." >> + (declare (debug (stringp body)) >> + (indent 1)) >> + `(with-current-buffer (get-buffer-create "*Messages*") >> + (save-restriction >> + (narrow-to-region (point-max) (point-max)) >> + ,@body >> + (should (string-match-p ,value (buffer-string)))))) > > I don't like this implementation. This strategy is used in autorevert-tests.el and filenotify-tests.el, which is where I copied it from. So those should be changed too. > 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. That would definitely be helpful. >> + (message "") ; clear the echo area >> + (kmacro-tests-should-match-message "Type e to repeat macro" > > Why is that call to 'message' necessary here? I suspect this is one > symptom of the fragility of kmacro-tests-should-match-message that I > mentioned above. Actually not. I was attempting to write a regression for bug#11817, which was about the "Type e to repeat macro" not showing up in the echo area. But kmacro-call-macro doesn't put up the message if there's already a message. I just looked into the history of that bit of code, and kmacro-call-macro's check of (current-message) is actually another bug fix, for bug#3412. >> +(kmacro-tests-deftest kmacro-tests-test-ring-commands-when-no-macros () >> + "Ring commands give appropriate message when no macros exist." >> + (dolist (cmd '((kmacro-cycle-ring-next nil) >> + (kmacro-cycle-ring-previous nil) >> + (kmacro-swap-ring) >> + (kmacro-delete-ring-head) >> + (kmacro-view-ring-2nd) >> + (kmacro-call-ring-2nd nil) >> + (kmacro-view-macro))) >> + (kmacro-tests-should-match-message "No keyboard macro defined" >> + (apply #'funcall cmd)))) > ^^^^^^^^^^^^^^^^^^^^^ > Why not ert-simulate-command? I'll make that change. What do you think about changing ert-simulate-command to set current-prefix-arg? That would be very helpful. >> + ;; I'm attempting to make the test work even if keys have been >> + ;; rebound, but if this is failing try emacs -Q first. > > If this comment is still valid, then many other parts of the test have > the same problem, because they clearly assume the default key > bindings. That comment is out of date, since kmacro-tests-keymap should fix the problem. I'll remove it.