From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Date: Wed, 24 Mar 2021 13:46:57 +0000 Message-ID: References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6272"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47320@debbugs.gnu.org, Michael Albinus To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 24 14:48:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lP3rn-0001Ub-GK for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 14:48:11 +0100 Original-Received: from localhost ([::1]:57616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lP3rm-0003MM-Eg for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 09:48:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP3re-0003M2-UW for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 09:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lP3re-0006wN-FE for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 09:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lP3re-0005x4-Dj for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 09:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Mar 2021 13:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs Original-Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.161659362722817 (code B ref 47320); Wed, 24 Mar 2021 13:48:02 +0000 Original-Received: (at 47320) by debbugs.gnu.org; 24 Mar 2021 13:47:07 +0000 Original-Received: from localhost ([127.0.0.1]:34350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP3qk-0005vx-U2 for submit@debbugs.gnu.org; Wed, 24 Mar 2021 09:47:07 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:38710 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lP3qi-0005vR-M5 for 47320@debbugs.gnu.org; Wed, 24 Mar 2021 09:47:05 -0400 Original-Received: (qmail 81778 invoked by uid 3782); 24 Mar 2021 13:46:58 -0000 Original-Received: from acm.muc.de (p4fe15b2f.dip0.t-ipconnect.de [79.225.91.47]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 24 Mar 2021 14:46:57 +0100 Original-Received: (qmail 8028 invoked by uid 1000); 24 Mar 2021 13:46:57 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:202945 Archived-At: Hello, Joćo, Thanks for the positive reaction! On Tue, Mar 23, 2021 at 15:59:03 +0000, Joćo Tįvora wrote: > As the author of electric-tests.el, I'm fine with either approach. > Michael's would seem more integrated, at a glance, not sure how hard it is > to switch to it. I'd have to see that patch. Joćo I'm having some difficulty getting my head around the "explanation" functionality of ert, which leans me towards my initial plan. Here's the patch (actually written quite a long time ago) I would like to merge into electric-tests.el: diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 62a42b7fe4..44b3d8b672 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -50,7 +50,8 @@ save-electric-modes `(call-with-saved-electric-modes #'(lambda () ,@body))) (defun electric-pair-test-for (fixture where char expected-string - expected-point mode bindings fixture-fn) + expected-point mode bindings + fixture-fn &optional doc-string) (with-temp-buffer (funcall mode) (insert fixture) @@ -63,6 +64,14 @@ electric-pair-test-for (mapcar #'car bindings) (mapcar #'cdr bindings) (call-interactively (key-binding `[,last-command-event]))))) + (when + (and doc-string + (not + (and + (equal (buffer-substring-no-properties (point-min) (point-max)) + expected-string) + (equal (point) expected-point)))) + (message "\n%s\n" doc-string)) (should (equal (buffer-substring-no-properties (point-min) (point-max)) expected-string)) (should (equal (point) @@ -109,14 +118,9 @@ electric-pair-test-for (fixture (format "%s%s%s" prefix fixture suffix)) (expected-string (format "%s%s%s" prefix expected-string suffix)) (expected-point (+ (length prefix) expected-point)) - (pos (+ (length prefix) pos))) - `(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s" - name - (1+ pos) - mode - extra-desc)) - () - ,(format "Electricity test in a `%s' buffer.\n + (pos (+ (length prefix) pos)) + (doc-string + (format "Electricity test in a `%s' buffer.\n Start with point at %d in a %d-char-long buffer like this one: @@ -143,7 +147,14 @@ electric-pair-test-for char (if (string= fixture expected-string) "stay" "become") (replace-regexp-in-string "\n" "\\\\n" expected-string) - expected-point) + expected-point))) + `(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s" + name + (1+ pos) + mode + extra-desc)) + () + ,doc-string (electric-pair-test-for ,fixture ,(1+ pos) ,char @@ -151,7 +162,8 @@ electric-pair-test-for ,expected-point ',mode ,bindings - ,fixture-fn))))) + ,fixture-fn + ,doc-string))))) (cl-defmacro define-electric-pair-test (name fixture -- Alan Mackenzie (Nuremberg, Germany).