From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Date: Wed, 24 Mar 2021 20:10:48 +0000 Message-ID: References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000bbc23705be4de5b2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39101"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Albinus , 47320-done@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 24 21:25:03 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 1lPA3p-000A1d-Im for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 21:25:01 +0100 Original-Received: from localhost ([::1]:41600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPA3o-000173-IE for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 16:25:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP9rG-0001Br-S0 for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 16:12:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lP9rG-0001hk-KK for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 16:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lP9rG-0003ds-Gj for bug-gnu-emacs@gnu.org; Wed, 24 Mar 2021 16:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Mar 2021 20:12: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-done@debbugs.gnu.org id=D47320.161661666713925 (code D ref 47320); Wed, 24 Mar 2021 20:12:02 +0000 Original-Received: (at 47320-done) by debbugs.gnu.org; 24 Mar 2021 20:11:07 +0000 Original-Received: from localhost ([127.0.0.1]:36146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP9qM-0003cX-Ut for submit@debbugs.gnu.org; Wed, 24 Mar 2021 16:11:07 -0400 Original-Received: from mail-il1-f178.google.com ([209.85.166.178]:41788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP9qL-0003bc-91 for 47320-done@debbugs.gnu.org; Wed, 24 Mar 2021 16:11:06 -0400 Original-Received: by mail-il1-f178.google.com with SMTP id r8so157993ilo.8 for <47320-done@debbugs.gnu.org>; Wed, 24 Mar 2021 13:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HFHXzzY+hvqKVJ/60ph3+qLEGjuwKqsGac177/UbnMc=; b=VQFChbhPrDot0mjt3pGRIGiwkIo3WpLXKvq2CRzhubV2BKIDv3K/EuVEpJAgeH6P8r wev0B3XDNqppSS7ZtRsJRy83sZ5d/LG1OC4R6lrom6+t0uaCX7c4KYrrGYCyPnsPQYR9 Qf3I17UauyhD7mjb6cWEKwXlJJ1p1XuMbIMlDue8/OiO5vW9tkOJEJNfcT4OYOIWKUzK O4CTxuw3eaOC7XqcwP3f3l3ehIceGWzOLKeZcg+AxZf4tL9IxKLfUnGXMls+zQrsmz37 I6Ap1S+Y/oVq5JBbynwfDYDpv6nQtqG74lLHD/dwOMhz7hKftINUjhR3l+YvGtID0uoo RaOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HFHXzzY+hvqKVJ/60ph3+qLEGjuwKqsGac177/UbnMc=; b=qD7e4HLS+QfpUNMWaDBbvdXva15be8ccaixvaGPLqkszLwnO4BdCK39B77m3oxqMAb VBAVSz6TA0X6QXrhBWlCXkrPKlhFMVEQFON8n3kURqHcTgaIwWuqSnT/TdCmOFcwrC+B mLCVMauNnYlEFLHOONLtL5WvSDb3nfBfnioTRed6MJBN8XSherjPJ8EhPsvh80EsMiPU gnbgqh7xqJ7XHDvHPYVeMterxSQvZHU1KPebPrQ/HV8TwrVg4dbnJ8BNfcMRcP0jIEIL fB7MxAQYQQ/n96p0Gp2aSxhfrQfwjMYxNg+oK5Ayha6a3SU946Q7+gukIUQ71eJpoUUw SJFw== X-Gm-Message-State: AOAM531iG3tgkN+GTQ0QyQmDE3sdcqNO0cBMckfvrWKiAKiBhFq6FMvD +7yTjrN4fxq1Qz3LZQrw4AATD5+zUB9DBGRxF5o= X-Google-Smtp-Source: ABdhPJyqXs70SXtzFqZhTWYr9CRMPAun6vY9kpY4fqbsvhp2NVjA95YMA1t7FhVDZVqK3EeBBFEkUOQVJQnR7OlR0Rg= X-Received: by 2002:a05:6e02:1069:: with SMTP id q9mr4113758ilj.97.1616616659597; Wed, 24 Mar 2021 13:10:59 -0700 (PDT) In-Reply-To: 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:202964 Archived-At: --000000000000bbc23705be4de5b2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Alan, > I just committed the patch as it was. Sorry. I don't much see the point in asking for comments from people and then proceeding to ignore the simplest request for adjustments outright. You did write "if there are no objections...". Well I had a small objection. I get it that following Michael's idea, which is probably better, takes a little bit more work, but a simple adjustment to avoid code repetition could certainly be accommodated. FWIW I've quickly tried with this version and it seems to work fine: (defun electric-pair-test-for (fixture where char expected-string expected-point mode bindings fixture-fn &optional doc-string) (with-temp-buffer (funcall mode) (insert fixture) (save-electric-modes (let ((last-command-event char) (transient-mark-mode 'lambda)) (goto-char where) (funcall fixture-fn) (cl-progv (mapcar #'car bindings) (mapcar #'cdr bindings) (call-interactively (key-binding `[,last-command-event]))))) (unless (equal (buffer-substring-no-properties (point-min) (point-max)) expected-string) (when doc-string (message "\n%s\n" doc-string)) (ert-fail (format "buffer contents don't match! (observed %s, expected %s)" (buffer-string) expected-string))) (unless (equal (point) expected-point) (when doc-string (message "\n%s\n" doc-string)) (ert-fail (format "point isn't where it was supposed to be! (observed %s, expected %s)" (point) expected-point))))) On Wed, Mar 24, 2021 at 7:42 PM Alan Mackenzie wrote: > > Hello again, Jo=C3=A3o. > > On Wed, Mar 24, 2021 at 14:02:58 +0000, Jo=C3=A3o T=C3=A1vora wrote: > > On Wed, Mar 24, 2021 at 1:46 PM Alan Mackenzie wrote: > > > > 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: > > > As far as I understand, this just stores the big explanation string in > > a variable, and uses it both for putting into the `ert-deftest` 's docstring > > as well as for logging with message(), right? If so, it's fine to add. > > > Maybe you could leverage `ert-fail` instead of checking the test's > > main assertion twice, once in should, and once when deciding > > whether to log. > > In the end, I couldn't get that to work - the handler for the signal, in > outputting the doc string, replaced all the \n's with the octal > read-syntax, "\\12". This left the text readable only with effort. > > > I'd say, just check it once and put both logging and `ert-fail` inside the if. > > I just committed the patch as it was. Sorry. > > > Jo=C3=A3o > > -- > Alan Mackenzie (Nuremberg, Germany). --=20 Jo=C3=A3o T=C3=A1vora --000000000000bbc23705be4de5b2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Alan,

> I just committed the patch as it w= as.=C2=A0 Sorry.

I don't much see the point in asking for commen= ts from people
and then proceeding to ignore the simplest request f= or adjustments
outright.
You did write "if there ar= e no objections...". Well I had a small
objection. I get it that fo= llowing Michael's idea, which is probably
better, takes a little bit= more work, but a simple adjustment
to avoid code repetition could certa= inly be accommodated.

FWIW I've quickly tried with this version = and it seems to work
fine:

(defun electric-pair-test-for (fixture= where char expected-string
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0expected-point mode bindings
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fixture-fn &optional do= c-string)
=C2=A0 (with-temp-buffer
=C2=A0 =C2=A0 (funcall mode)
= =C2=A0 =C2=A0 (insert fixture)
=C2=A0 =C2=A0 (save-electric-modes
=C2= =A0 =C2=A0 =C2=A0 (let ((last-command-event char)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (transient-mark-mode 'lambda))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (goto-char where)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (funcall fix= ture-fn)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (cl-progv
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (mapcar #'car bindings)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (mapcar #'cdr bindings)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (call-interactively (key-binding `[,last-command-event])))))<= br>=C2=A0 =C2=A0 (unless (equal (buffer-substring-no-properties (point-min)= (point-max))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0expected-string)
=C2=A0 =C2=A0 =C2=A0 (when doc-string (mes= sage "\n%s\n" doc-string))
=C2=A0 =C2=A0 =C2=A0 (ert-fail (for= mat
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= buffer contents don't match! (observed %s, expected %s)"
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(buffer-string) exp= ected-string)))
=C2=A0 =C2=A0 (unless (equal (point) expected-point)
= =C2=A0 =C2=A0 =C2=A0 (when doc-string (message "\n%s\n" doc-strin= g))
=C2=A0 =C2=A0 =C2=A0 (ert-fail
=C2=A0 =C2=A0 =C2=A0 =C2=A0(format= "point isn't where it was supposed to be! (observed %s, expected = %s)"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(point)= expected-point)))))




On Wed, Mar 24, 2021 at 7:42 PM Ala= n Mackenzie <acm@muc.de> wrote:
= >
> Hello again, Jo=C3=A3o.
>
> On Wed, Mar 24, 2021 a= t 14:02:58 +0000, Jo=C3=A3o T=C3=A1vora wrote:
> > On Wed, Mar 24,= 2021 at 1:46 PM Alan Mackenzie <acm@muc.d= e> wrote:
>
> > > I'm having some difficulty g= etting my head around the "explanation"
> > > functio= nality 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:
>
> &g= t; As far as I understand, this just stores the big explanation string in> > a variable, and uses it both for putting into the `ert-deftest`= 's docstring
> > as well as for logging with message(), right= ?=C2=A0 If so, it's fine to add.
>
> > Maybe you could l= everage `ert-fail` instead of checking the test's
> > main ass= ertion twice, once in should, and once when deciding
> > whether t= o log.
>
> In the end, I couldn't get that to work - the ha= ndler for the signal, in
> outputting the doc string, replaced all th= e \n's with the octal
> read-syntax, "\\12".=C2=A0 This= left the text readable only with effort.
>
> > I'd say,= just check it once and put both logging and `ert-fail` inside the if.
&= gt;
> I just committed the patch as it was.=C2=A0 Sorry.
>
&= gt; > Jo=C3=A3o
>
> --
> Alan Mackenzie (Nuremberg, Ge= rmany).



--
Jo=C3=A3o T=C3=A1vora
--000000000000bbc23705be4de5b2--