From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Mar 2021 14:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 47320@debbugs.gnu.org Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16164230886352 (code B ref -1); Mon, 22 Mar 2021 14:25:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Mar 2021 14:24:48 +0000 Received: from localhost ([127.0.0.1]:58213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOLU8-0001eO-7O for submit@debbugs.gnu.org; Mon, 22 Mar 2021 10:24:48 -0400 Received: from lists.gnu.org ([209.51.188.17]:58932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOLU6-0001eE-N9 for submit@debbugs.gnu.org; Mon, 22 Mar 2021 10:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOLU6-0004Sx-Dx for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 10:24:46 -0400 Received: from colin.muc.de ([193.149.48.1]:19058 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1lOLU3-0000mQ-Th for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 10:24:46 -0400 Received: (qmail 55796 invoked by uid 3782); 22 Mar 2021 14:24:38 -0000 Received: from acm.muc.de (p4fe15b2f.dip0.t-ipconnect.de [79.225.91.47]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 22 Mar 2021 15:24:38 +0100 Received: (qmail 6312 invoked by uid 1000); 22 Mar 2021 14:24:37 -0000 Date: Mon, 22 Mar 2021 14:24:37 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) 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 (--) Hello, Emacs. When running make check, and a failure occurs in electric-tests.elc, the resulting output in electric-tests.log is frustratingly cryptic. Although one can fairly easily get back to the source code for the test in electric-tests.el, it is difficult to reconstruct the snippet of text on which the test was performed. This is because the tests are (necessarily) generated by fairly inscrutable macros. This is a shame, since each generated test has its own exceptionally clear generated doc-string. An example of such a doc string is: ######################################################################### Electricity test in a `c-mode' buffer. Start with point at 7 in a 7-char-long buffer like this one: |"foo \"| (buffer start and end are denoted by `|') Now call this: #'electric-quote-local-mode Ensure the following bindings: '((electric-quote-replace-double . t) (electric-quote-comment . t) (electric-quote-string . t)) Now press the key for: " The buffer's contents should become: |"foo \""| , and point should be at 7. ######################################################################### My proposal is that on a test failure, this generated doc-string should be output along with the other failure stuff. It doesn't actually add all that much bulk to the .log file. Here is patch which does this. If there are no objections, I will commit it in a day or two. 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). From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Mar 2021 08:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 47320@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.16164895967519 (code B ref 47320); Tue, 23 Mar 2021 08:54:01 +0000 Received: (at 47320) by debbugs.gnu.org; 23 Mar 2021 08:53:16 +0000 Received: from localhost ([127.0.0.1]:59491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOcmq-0001xD-6d for submit@debbugs.gnu.org; Tue, 23 Mar 2021 04:53:16 -0400 Received: from mout.gmx.net ([212.227.15.18]:33027) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOcmo-0001wy-71 for 47320@debbugs.gnu.org; Tue, 23 Mar 2021 04:53:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1616489586; bh=ZOkJSINRvQzMF5Pp+Zv+fBZrSTTFHeXRyd8AjWIJ60k=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=gdALalbNfWHn7U9QSGZ0eCNCgnZMeWIwTsMlZWpWz5zDP88Q96gUj9ODrT+h+pKQc /HEjut7uJomIS3WP5QyUsRs9rULZHk26KNj7Jjck5zLxvGoYQle2uDRx8jeYeUEsn1 rudA6glFm8ffmBcI2y3jRcVnzgfxqMmJjbGwuXgI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from gandalf.gmx.de ([212.91.243.117]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWRVh-1l9Xvm2nmd-00XvVq; Tue, 23 Mar 2021 09:53:05 +0100 From: Michael Albinus References: Date: Tue, 23 Mar 2021 09:53:04 +0100 In-Reply-To: (Alan Mackenzie's message of "Mon, 22 Mar 2021 14:24:37 +0000") Message-ID: <87v99i5k0f.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:Ls/HoeXPtkLA/XBIQbDTPEkelZzK8Mpw01tYSPRmyegjAC2qwtF xnKkgX7PYS4kYn8x4YWx0YXrFTEQkiqKU+tixFQRri0Itu/hl9yhtqCaMo5WTc4tQYRSLpi oz4pEM2diZrem4W76shQoo+ICf6X9qR67B7/PLuY3/1C5SJcqjM2gbVmKfbn+vS/UciVM3i hJGb1nO3Q7rysYDc6sL7g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:TdiNMqJItVY=:lju3Zgp3tohu3g6mgyoCpl V2ItiSi7wG0vgZafBvwvO1u/Dba+PfzzdLsrgk55Y/+RNE298v36TnEWH36cDSLhj5+Jr0OzC MZ5BrKdiyLGguu4+D3iW1S04MIKmn2be+e1eST5USnQsishx7FbueVgDJfLSp1t38dy70Rzvn XH7LcFb9tfvbyXYBVG1Kf5L+kmk8HeqyOr9BOfVQq1gckHZ/czo/fkRR2z4pnan/Y88eDqnuk x+JHMVe1zcUwpp6367D+YEVZAbdKFmQs7wfd7FvdD2tXYe8MGnDnKKX1n/BtGhnHVWjCc7+jg 2ehiepSEiBKoPIJ9fbqz1j1r6gIJdmTBQD/4sMLLrnMaFHdFR0xXjGG1JvUlidSLtwhEdcLw2 Uifsm5q1WleJKiBQgh6qHLbreA+NIMKk42X7xP/QxBtCNEknhoeTy86yPtg6mg6Pdf9gqoBrz 8gu2whRiz2sNJFlof+G5pW/e3Ra7Caw4ZIWK5OdN1T35x0/vFrk0Tbe0FKvHCw0B581rVZbtc SJbUs1CG3v7i+rTSI4blQeKXe2YmmusayuFbnk3sJv/P5yZlImjhKNBqqxS3tpsFtdShoOHgd XlXEjKRYxZ7TOl1j1lCZxxq0R6ZDvp+SmQirJGZJEZVv5ljch3H9G1JHVfayX9ni4FwEXjSss P4SbWiA9IZjrzwWhWmq8olLYJb6orCygrdgrIsoJlAMCuvrtmQ1hFpZqGFfrdmpSFdAiGz+dC cfICMXn/K5SIP59ZTbt6LUPvvC44ZuKNTstKgnpOYRTFzkcHdpgADOH2eU5/YDP9C3FPii397 VM70gSdOeLvUE826Fx7FLKfUTGSJeGM9zWLyNkMvKIkDpbOgUkoEEiOwr+J0rXy7P63LcxkZt uAajHVT8kCMoyQcjEvezxlolTEFblxtOREjH55mh8EldANRTYqP1ppk+K6xDEs+sC/vH+lYJe fxIsv+T7HyRKxp2EwXdpAndIggOTuv1uRjjR/8Jvj9iZsMEGhapXjvA33NSuwSsmNwYR/G4yU 7s3CL2ixXbwkh+xLBYBYE9EhiO1ZzZPrg4+dqyQ9zzD82Zdi2q8ByBXAh+tvz+bAfOZMjh5CN vHK8dUnXgb6iLJDuRz1ZamN/qG4CN0qdB1UMVyIkEDkny/n3dAYBixhByQxs4txveJHyBEe4X 8N1sUcLHSeHCHCBdXkPL+5tOB0CbqoriRsiE15OLnwjauUe+Hkv6Hwd08BLJdtghsucaKNhPy aIsvbePn2CVkJKZqz X-Spam-Score: -0.7 (/) 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: -1.7 (-) Alan Mackenzie writes: > Hello, Emacs. Hi Alan, > My proposal is that on a test failure, this generated doc-string should > be output along with the other failure stuff. It doesn't actually add > all that much bulk to the .log file. > > Here is patch which does this. If there are no objections, I will > commit it in a day or two. There is the explainer functionality in ert, see (info "(ert)Defining Explanation Functions") I recommend to use it, for better readability of the test code. Examples are in our test files. Best regards, Michael. From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Mar 2021 14:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Albinus Cc: 47320@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.161651087127312 (code B ref 47320); Tue, 23 Mar 2021 14:48:02 +0000 Received: (at 47320) by debbugs.gnu.org; 23 Mar 2021 14:47:51 +0000 Received: from localhost ([127.0.0.1]:60941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOiJz-00076R-9B for submit@debbugs.gnu.org; Tue, 23 Mar 2021 10:47:51 -0400 Received: from colin.muc.de ([193.149.48.1]:57655 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lOiJw-00076B-Ox for 47320@debbugs.gnu.org; Tue, 23 Mar 2021 10:47:50 -0400 Received: (qmail 55215 invoked by uid 3782); 23 Mar 2021 14:47:42 -0000 Received: from acm.muc.de (p4fe159d5.dip0.t-ipconnect.de [79.225.89.213]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 23 Mar 2021 15:47:41 +0100 Received: (qmail 7296 invoked by uid 1000); 23 Mar 2021 14:47:41 -0000 Date: Tue, 23 Mar 2021 14:47:41 +0000 Message-ID: References: <87v99i5k0f.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87v99i5k0f.fsf@gmx.de> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) 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: -1.0 (-) Hello, Michael. On Tue, Mar 23, 2021 at 09:53:04 +0100, Michael Albinus wrote: > Alan Mackenzie writes: > > Hello, Emacs. > Hi Alan, > > My proposal is that on a test failure, this generated doc-string should > > be output along with the other failure stuff. It doesn't actually add > > all that much bulk to the .log file. > > Here is patch which does this. If there are no objections, I will > > commit it in a day or two. > There is the explainer functionality in ert, see > (info "(ert)Defining Explanation Functions") That description is rather terse. In fact it is incomplete - it does not say when the explanation function gets called, nor does it say what is done with any resulting explanation. It looks like a explanation function needs to duplicate the test code of the test being explained - it seems the function has no access to the internal state of the test. I only wish to print the extra information when there is a test failure. Otherwise the information in electric-tests.log would be swamped by pointless voluminous doc strings. Or am I missing something? > I recommend to use it, for better readability of the test code. Examples > are in our test files. Thanks! > Best regards, Michael. -- Alan Mackenzie (Nuremberg, Germany). From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Mar 2021 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 47320@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.16165131006720 (code B ref 47320); Tue, 23 Mar 2021 15:25:02 +0000 Received: (at 47320) by debbugs.gnu.org; 23 Mar 2021 15:25:00 +0000 Received: from localhost ([127.0.0.1]:32769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOitw-0001kK-BK for submit@debbugs.gnu.org; Tue, 23 Mar 2021 11:25:00 -0400 Received: from mout.gmx.net ([212.227.15.15]:58601) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOitt-0001k3-Bl for 47320@debbugs.gnu.org; Tue, 23 Mar 2021 11:24:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1616513085; bh=OEum+GuWZY2xG64Q/pzD/uWRI0jA3jji7tazw8m3O5Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=ZVbi6cotb24jr+8HvXF2RVxMC3JoU8pzGoL9CYMC0xSoZ9+einaZvXCYrjO7VTE0t nO8DrLrgyuOsSOjQ/7F6YMX2UEBn2ZvSZu9+PxPCX8NI6cgmQJGcbRaDRKN4pbpGPQ uSZnF99wfCmM+1EbsxWoORLgwd+Ev08oi7kLIUSw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from gandalf.gmx.de ([212.91.243.117]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N95iH-1lloRW1I2x-016B3M; Tue, 23 Mar 2021 16:24:45 +0100 From: Michael Albinus References: <87v99i5k0f.fsf@gmx.de> Date: Tue, 23 Mar 2021 16:24:43 +0100 In-Reply-To: (Alan Mackenzie's message of "Tue, 23 Mar 2021 14:47:41 +0000") Message-ID: <877dlx3nb8.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:AjiWZEgprz+TXwuUPtBUewcDgbiZUMzve6dHnIqMp8ekei2a+vb 1Z0kk3zVGSCJvaacLQne80sHaEqoS9nQakipdVr0a81PsMpqr4ekscQlMonIVMiZ1OO5F4v a5/IK+z2m7uzImFSnz6zRLRYMOVUct987TCyx0E/3nGcIIdZTK4Oq4luc7OUie5AYbJ4z6T 9tL8GwFHb4Ia5xgCXZA5Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:UHJi93NVDl0=:q26PadmavSwhTbDStlU0ui SbxNj/a+tgi7EyJKA6Vc3JGU9HXMzm30Z8fK3h6YBpVUf4X0zVhre4JLkAyQHpzEi52zFB9/B QfKNz57KlbZNApZwuzUMAlTpg3tTrJcfAz29bjHONQNbTMt/1k61OuRAWiS+X4ZrhaxlYl2FL OsQ7VFtJJDxK+8xwB9KlwAsHtdtoB77UZF5rK6mbKMKes+wJGbvKuAmgiVbkOV7GxRHdXdpmt I11po0IaxTjyfJYqzcOCRkFb0niAa5dpW3a5tM4RTplQuq9/VkXNN4WcHwV5PfbeYmHfu+Qfx POlduQ5cDcuPZUrUcP/S0fExU/viwerUZE5x2+K8KOsivKqo1yj5GfzRl3trDVwB8wiQREi+i tb/b08BcNUFu6vt8Mj64MYTWnKQio78Ff3oCRVX7hJSytctcXWjG7PsRY3odQjgH2dUKpyA2h 9+g6KIoJr8O5CW8x6Zo9XizXkk1JD2tGK53WbVvDdyQaZGQXL1hqqAuosnvtTPyBalfih9JAp DVm0omnQfcI4dOD2klFwaM8g6p9EgaxKHcYvwHf0qXZ2/SD2s0/4B1J2mvOj8bAxpFtAPIHsp 5WrIBzaRMmhtFXdNXU5IISyCBQHDs46A8ld3sJyAxPAssysuXqIYczrRGXLuGVTfSagCHn8Rn INQ853IQ36yWVh8pAg1GDNSDwyDxfLa2MVZlLfXJAq2exv0r4E9HB51ebJpu9f866SUfBASCV WHuMkYIKbTY7orCbkUI0rj7N8X9dhHsOpquCcQqt1NFd4KXJukqPgOE1rVNV2hELckKEUNZV+ 2wWQ0ebnDhy0d62q2+XZf8EESdLT3g+y5u/i5R1lMu+4T65Y5c5cToaJeLSsGm24LnSIz88pP +5WtF2dHF2fqTvlRv9tg== Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) 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: -1.7 (-) Alan Mackenzie writes: > Hello, Michael. Hi Alan, >> There is the explainer functionality in ert, see > >> (info "(ert)Defining Explanation Functions") > > That description is rather terse. In fact it is incomplete - it does > not say when the explanation function gets called, nor does it say what > is done with any resulting explanation. 100% d'accord. The ert manual isn't as helpful as it should ... > It looks like a explanation function needs to duplicate the test code of > the test being explained - it seems the function has no access to the > internal state of the test. No, it has full access to the test via the ert machinery. (ert-get-test SYMBOL) returns the test object which has been created via (ert-deftest SYMBOL-NAME ...) (ert-running-test) returns the test object of the test just running. With that test object, you have different access functions, like ert-test-name, ert-test-documentation, ert-test-most-recent-result; see cl-defstruct ert-test. And there are also some other defstructs, which give you convenience functions like ert-test-failed-p. > I only wish to print the extra information when there is a test failure. > Otherwise the information in electric-tests.log would be swamped by > pointless voluminous doc strings. The ert explainer writes only something for failed functions. > Or am I missing something? I've spent hours and hours to understand these ert functions. You might have a look on filenotify-tests.el or tramp-tests.el, for example. >> I recommend to use it, for better readability of the test code. Example= s >> are in our test files. > > Thanks! If needed, I could help you in setting upt these explainers. But I must confess, I have no idea about electrict-tests.el. For the beginning, you might look on this: =2D-8<---------------cut here---------------start------------->8--- (defun test-function () "The result." t) (defun test-function-explainer () "The explainer, a string." (format "%s: %s" (ert-test-name (ert-running-test)) (ert-test-documentat= ion (ert-running-test)))) (ert-deftest first-test () "Just the first test" (should (test-function))) (ert-deftest second-test () "Just the second test" (should-not (test-function))) (put 'test-function 'ert-explainer 'test-function-explainer) =2D-8<---------------cut here---------------end--------------->8--- If you run both tests, you get =2D-8<---------------cut here---------------start------------->8--- .F . first-test Just the first test passed F second-test Just the second test (ert-test-failed ((should-not (test-function)) :form (test-function) :value t :explanation "second-test: Just the second test")) =2D-8<---------------cut here---------------end--------------->8--- Best regards, Michael. From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el 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: Tue, 23 Mar 2021 16:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Michael Albinus Cc: Alan Mackenzie , 47320@debbugs.gnu.org Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.161651516910061 (code B ref 47320); Tue, 23 Mar 2021 16:00:02 +0000 Received: (at 47320) by debbugs.gnu.org; 23 Mar 2021 15:59:29 +0000 Received: from localhost ([127.0.0.1]:32811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOjRI-0002cC-LT for submit@debbugs.gnu.org; Tue, 23 Mar 2021 11:59:29 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:39623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOjRG-0002bw-6x for 47320@debbugs.gnu.org; Tue, 23 Mar 2021 11:59:27 -0400 Received: by mail-io1-f42.google.com with SMTP id k25so6088009iob.6 for <47320@debbugs.gnu.org>; Tue, 23 Mar 2021 08:59:26 -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=wmTFCmfHordcflPHB1qIHdje7gJdo3i2lPdD1qpOVuc=; b=NSqHpZcngoD/T97ydL7Q+VSZ4RvffiIB0JBY5tmjSS0vOtX0kcaAg5p+orX2Pd+9Xv yWuMFUgbiYYoUamq4Vq19JCrJKN+h82NxS2J1ZZ0ADXFpjFncRliEc5DlJ0N6kcPyKu6 qVyWX5M3KKwzwI3XbWRY+DTy7ApRO8SAOckc2hzRdUyaO9PPrqT0Zq8r+OUKvxDSx+TQ ATmNLZZ+CrYKXCsoM7t+t+0Pp6a8fchaNy/q2UHD/eu4VemR7QJoRO68CvNj4UbYhSQF gbF7BMIAAchtW2FK10YJYrWodPw7KTsNTgf0Vfpe0JRSyP0KnPKFNCa/zvnNS0WCEElC rXcg== 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=wmTFCmfHordcflPHB1qIHdje7gJdo3i2lPdD1qpOVuc=; b=AXegbdPnMS1z4xma3KD+4FxxznPoerdOkiL/2tbARyvLDvUjrMApwdQLcY0eW5CELq LXNc2Ie5RCz8s8ltsu1+E/POMjF1K7Yfcfajqo87gZQqXoDwGAYXltsM3RUErs/xVYk3 4xlnB6CLJ2kPNjAvkDlkx+VD+DPgFfnhpoi/9ttDLwqPzMblXoVH6/MtzhtduDBvIEk3 QZ0scYVWinZp+RtWVMJUhcgNacWl1oGm7gdTDWAahtKBgBckiIGXgOLVGijc0b7V67eM p2Jx+MVDzLb3SzENLtnRcMCB5esqwz8yXBlpey7SafuS4yuTf5qrpHk3v3qn/+bc76+J sxzQ== X-Gm-Message-State: AOAM532XzZ1FKsgBN4CIcf707bhofYdo9h0BhdDO0WXlqReNb8OgHV0t nxQ92piKxWg5QyGevyM5sc3ldrgPuWeHDucWPnE= X-Google-Smtp-Source: ABdhPJwyQQdQjLc7hDvDazFjlvTT1lwvx2gKG4JNYvY97gY816rCWyf2T9D8lz11tgLCGyX8pk5NTrmL8p+PaBXnzeA= X-Received: by 2002:a02:661c:: with SMTP id k28mr5228217jac.78.1616515160268; Tue, 23 Mar 2021 08:59:20 -0700 (PDT) MIME-Version: 1.0 References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> In-Reply-To: <877dlx3nb8.fsf@gmx.de> From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Date: Tue, 23 Mar 2021 15:59:03 +0000 Message-ID: Content-Type: multipart/alternative; boundary="000000000000e6e49705be364316" X-Spam-Score: 0.0 (/) 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: -1.0 (-) --000000000000e6e49705be364316 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=A3o On Tue, Mar 23, 2021, 15:24 Michael Albinus wrote: > Alan Mackenzie writes: > > > Hello, Michael. > > Hi Alan, > > >> There is the explainer functionality in ert, see > > > >> (info "(ert)Defining Explanation Functions") > > > > That description is rather terse. In fact it is incomplete - it does > > not say when the explanation function gets called, nor does it say what > > is done with any resulting explanation. > > 100% d'accord. The ert manual isn't as helpful as it should ... > > > It looks like a explanation function needs to duplicate the test code o= f > > the test being explained - it seems the function has no access to the > > internal state of the test. > > No, it has full access to the test via the ert machinery. > > (ert-get-test SYMBOL) returns the test object which has been created via > (ert-deftest SYMBOL-NAME ...) > > (ert-running-test) returns the test object of the test just running. > > With that test object, you have different access functions, like > ert-test-name, ert-test-documentation, ert-test-most-recent-result; see > cl-defstruct ert-test. And there are also some other defstructs, which > give you convenience functions like ert-test-failed-p. > > > I only wish to print the extra information when there is a test failure= . > > Otherwise the information in electric-tests.log would be swamped by > > pointless voluminous doc strings. > > The ert explainer writes only something for failed functions. > > > Or am I missing something? > > I've spent hours and hours to understand these > ert functions. You might have a look on filenotify-tests.el or > tramp-tests.el, for example. > > >> I recommend to use it, for better readability of the test code. Exampl= es > >> are in our test files. > > > > Thanks! > > If needed, I could help you in setting upt these explainers. But I must > confess, I have no idea about electrict-tests.el. > > For the beginning, you might look on this: > > --8<---------------cut here---------------start------------->8--- > (defun test-function () > "The result." > t) > > (defun test-function-explainer () > "The explainer, a string." > (format "%s: %s" (ert-test-name (ert-running-test)) > (ert-test-documentation (ert-running-test)))) > > (ert-deftest first-test () > "Just the first test" > (should (test-function))) > > (ert-deftest second-test () > "Just the second test" > (should-not (test-function))) > > (put 'test-function 'ert-explainer > 'test-function-explainer) > --8<---------------cut here---------------end--------------->8--- > > If you run both tests, you get > > --8<---------------cut here---------------start------------->8--- > .F > > . first-test > Just the first test > passed > > F second-test > Just the second test > (ert-test-failed > ((should-not > (test-function)) > :form > (test-function) > :value t :explanation "second-test: Just the second test")) > --8<---------------cut here---------------end--------------->8--- > > Best regards, Michael. > --000000000000e6e49705be364316 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
As the author of electric-tests.el, I'm fine wit= h either approach. Michael's would seem more integrated, at a glance, n= ot sure how hard it is to switch to it. I'd have to see that patch. Jo= =C3=A3o

On Tue, Mar 23, 2021, 15:24 Michael Albinus <michael.albinus@gmx.de> wrote:
Alan Mackenzie <acm@muc.de> writes:

> Hello, Michael.

Hi Alan,

>> There is the explainer functionality in ert, see
>
>> (info "(ert)Defining Explanation Functions")
>
> That description is rather terse.=C2=A0 In fact it is incomplete - it = does
> not say when the explanation function gets called, nor does it say wha= t
> is done with any resulting explanation.

100% d'accord. The ert manual isn't as helpful as it should ...

> It looks like a explanation function needs to duplicate the test code = of
> the test being explained - it seems the function has no access to the<= br> > internal state of the test.

No, it has full access to the test via the ert machinery.

(ert-get-test SYMBOL) returns the test object which has been created via (ert-deftest SYMBOL-NAME ...)

(ert-running-test) returns the test object of the test just running.

With that test object, you have different access functions, like
ert-test-name, ert-test-documentation, ert-test-most-recent-result; see
cl-defstruct ert-test. And there are also some other defstructs, which
give you convenience functions like ert-test-failed-p.

> I only wish to print the extra information when there is a test failur= e.
> Otherwise the information in electric-tests.log would be swamped by > pointless voluminous doc strings.

The ert explainer writes only something for failed functions.

> Or am I missing something?

<shameless advertisement>I've spent hours and hours to understand= these
ert functions. You might have a look on filenotify-tests.el or
tramp-tests.el, for example.</>

>> I recommend to use it, for better readability of the test code. Ex= amples
>> are in our test files.
>
> Thanks!

If needed, I could help you in setting upt these explainers. But I must
confess, I have no idea about electrict-tests.el.

For the beginning, you might look on this:

--8<---------------cut here---------------start------------->8---
(defun test-function ()
=C2=A0 "The result."
=C2=A0 t)

(defun test-function-explainer ()
=C2=A0 "The explainer, a string."
=C2=A0 (format "%s: %s" (ert-test-name (ert-running-test)) (ert-t= est-documentation (ert-running-test))))

(ert-deftest first-test ()
=C2=A0 "Just the first test"
=C2=A0 (should (test-function)))

(ert-deftest second-test ()
=C2=A0 "Just the second test"
=C2=A0 (should-not (test-function)))

(put 'test-function 'ert-explainer
=C2=A0 =C2=A0 =C2=A0'test-function-explainer)
--8<---------------cut here---------------end--------------->8---

If you run both tests, you get

--8<---------------cut here---------------start------------->8---
.F

. first-test
=C2=A0 =C2=A0 Just the first test
=C2=A0 =C2=A0 passed

F second-test
=C2=A0 =C2=A0 Just the second test
=C2=A0 =C2=A0 (ert-test-failed
=C2=A0 =C2=A0 =C2=A0((should-not
=C2=A0 =C2=A0 =C2=A0 =C2=A0(test-function))
=C2=A0 =C2=A0 =C2=A0 :form
=C2=A0 =C2=A0 =C2=A0 (test-function)
=C2=A0 =C2=A0 =C2=A0 :value t :explanation "second-test: Just the seco= nd test"))
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.
--000000000000e6e49705be364316-- From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el 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 X-GNU-PR-Keywords: To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Cc: 47320@debbugs.gnu.org, Michael Albinus Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.161659362722817 (code B ref 47320); Wed, 24 Mar 2021 13:48:02 +0000 Received: (at 47320) by debbugs.gnu.org; 24 Mar 2021 13:47:07 +0000 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 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 Received: (qmail 81778 invoked by uid 3782); 24 Mar 2021 13:46:58 -0000 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 Received: (qmail 8028 invoked by uid 1000); 24 Mar 2021 13:46:57 -0000 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) 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: -1.0 (-) 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). From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el 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 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 47320@debbugs.gnu.org, Michael Albinus Received: via spool by 47320-submit@debbugs.gnu.org id=B47320.161659459725637 (code B ref 47320); Wed, 24 Mar 2021 14:04:02 +0000 Received: (at 47320) by debbugs.gnu.org; 24 Mar 2021 14:03:17 +0000 Received: from localhost ([127.0.0.1]:35736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP46P-0006fR-CN for submit@debbugs.gnu.org; Wed, 24 Mar 2021 10:03:17 -0400 Received: from mail-io1-f45.google.com ([209.85.166.45]:43571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP46N-0006fE-Ih for 47320@debbugs.gnu.org; Wed, 24 Mar 2021 10:03:16 -0400 Received: by mail-io1-f45.google.com with SMTP id z136so21584808iof.10 for <47320@debbugs.gnu.org>; Wed, 24 Mar 2021 07:03:15 -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:content-transfer-encoding; bh=pSUrBggmKHaoGUv/B334cJRuzA3hc//2E+js4F2TI98=; b=ng973/7J3nbqA+oXFSlYyXFnWUL3kj6gjg9z9XsWDNFWPoh6dG9weWrUt5Wb96uKh0 au5SiZY5WCROIOPAZEpWzLRY5kNzhUIcZDl72G8mUTRDWtgqUq3I/BCMOoRch7V8RQUE uK08fkovcf5es/5YXeTBwoJY5QHsbpDaPokN+b/0zrJT0WlT+SuA1wNr0iQRuikrBiNO QCiryR8U0caCf43c9r6aphsm1FFTRX1MKlO2ml6aOcnOyb1HM3auHMc0eA0r+/Ou4u01 6KYrrwUvjQ6/trwgjnPAx/0jo13iJrQNngs6kqsKDrDVQa3FOritdpSYmmYJ03sSonm8 1Q7g== 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:content-transfer-encoding; bh=pSUrBggmKHaoGUv/B334cJRuzA3hc//2E+js4F2TI98=; b=E1mK4b8VqRMWVMRPx/Tmvz75mHJ9nmV5SmJP8W1br91CYTF+gpzv/bjmSetLRa+T9r iPqn7CdWCmBiHN0h1DCzay4KaXX1m4qGYJdPj5zKxDE2JX0D3fM/5pxmKAmJrLC0VyEz PjlWZMwfpFc36pbR/3QUr+h0Pt5PtG51K5v3BVBP9qhaT/Bvq0ORqYi8FgOTzvoN6owH WEqXLvx6HSSxzpY9jj8VIMzCDk7k4Ti/3Z/Z2VO2i8/pMWxd4LUxrLISiC9PY2svB2Pm WTsjxYxx1wBKE7FpKCR3TeZibJO1I35XVeFfb/ApkfYSYcSvPz+D/b1dAET6go0RqYzH F6ew== X-Gm-Message-State: AOAM5307biCZ6P4yyFKZlxxVPVH0L8c7w7bv7FO4PM72xBbUm239+4oQ aC5pT8uKnWbCY1YO72ftDQTKZIqOqIM4Uj72nm4= X-Google-Smtp-Source: ABdhPJy+1YFcEPHaEF1d6xLpXlfwflSJW7DWzq+/51/0UkSRBF8tHV7IA4Vdm92dQRfNpk+HFFkUU24SuI7b0CrOtz4= X-Received: by 2002:a5e:8c16:: with SMTP id n22mr2595750ioj.156.1616594589893; Wed, 24 Mar 2021 07:03:09 -0700 (PDT) MIME-Version: 1.0 References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> In-Reply-To: From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Date: Wed, 24 Mar 2021 14:02:58 +0000 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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: -1.0 (-) Hello Alan, On Wed, Mar 24, 2021 at 1:46 PM Alan Mackenzie wrote: > Thanks for the positive reaction! Speak nothing of it! > 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 docstrin= g 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. I'd say, just check it once and put both logging and `ert-fail` inside the = if. Jo=C3=A3o From unknown Sun Aug 10 16:43:00 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Alan Mackenzie Subject: bug#47320: closed (Re: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el) Message-ID: References: X-Gnu-PR-Message: they-closed 47320 X-Gnu-PR-Package: emacs Reply-To: 47320@debbugs.gnu.org Date: Wed, 24 Mar 2021 19:44:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1616615042-10761-1" This is a multi-part message in MIME format... ------------=_1616615042-10761-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #47320: Improve failure reporting in test/lisp/electrict-tests.el which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 47320@debbugs.gnu.org. --=20 47320: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D47320 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1616615042-10761-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 47320-done) by debbugs.gnu.org; 24 Mar 2021 19:43:03 +0000 Received: from localhost ([127.0.0.1]:36126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP9PD-0002lk-DS for submit@debbugs.gnu.org; Wed, 24 Mar 2021 15:43:03 -0400 Received: from colin.muc.de ([193.149.48.1]:48298 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lP9PB-0002l9-UB for 47320-done@debbugs.gnu.org; Wed, 24 Mar 2021 15:43:02 -0400 Received: (qmail 22445 invoked by uid 3782); 24 Mar 2021 19:42:55 -0000 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 20:42:54 +0100 Received: (qmail 28584 invoked by uid 1000); 24 Mar 2021 19:42:54 -0000 Date: Wed, 24 Mar 2021 19:42:54 +0000 To: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= Subject: Re: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Message-ID: References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 47320-done Cc: Michael Albinus , 47320-done@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: -1.0 (-) Hello again, Joćo. On Wed, Mar 24, 2021 at 14:02:58 +0000, Joćo Tįvora 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ćo -- Alan Mackenzie (Nuremberg, Germany). ------------=_1616615042-10761-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 22 Mar 2021 14:24:48 +0000 Received: from localhost ([127.0.0.1]:58213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOLU8-0001eO-7O for submit@debbugs.gnu.org; Mon, 22 Mar 2021 10:24:48 -0400 Received: from lists.gnu.org ([209.51.188.17]:58932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOLU6-0001eE-N9 for submit@debbugs.gnu.org; Mon, 22 Mar 2021 10:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOLU6-0004Sx-Dx for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 10:24:46 -0400 Received: from colin.muc.de ([193.149.48.1]:19058 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1lOLU3-0000mQ-Th for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 10:24:46 -0400 Received: (qmail 55796 invoked by uid 3782); 22 Mar 2021 14:24:38 -0000 Received: from acm.muc.de (p4fe15b2f.dip0.t-ipconnect.de [79.225.91.47]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 22 Mar 2021 15:24:38 +0100 Received: (qmail 6312 invoked by uid 1000); 22 Mar 2021 14:24:37 -0000 Date: Mon, 22 Mar 2021 14:24:37 +0000 To: bug-gnu-emacs@gnu.org Subject: Improve failure reporting in test/lisp/electrict-tests.el Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= 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 (--) Hello, Emacs. When running make check, and a failure occurs in electric-tests.elc, the resulting output in electric-tests.log is frustratingly cryptic. Although one can fairly easily get back to the source code for the test in electric-tests.el, it is difficult to reconstruct the snippet of text on which the test was performed. This is because the tests are (necessarily) generated by fairly inscrutable macros. This is a shame, since each generated test has its own exceptionally clear generated doc-string. An example of such a doc string is: ######################################################################### Electricity test in a `c-mode' buffer. Start with point at 7 in a 7-char-long buffer like this one: |"foo \"| (buffer start and end are denoted by `|') Now call this: #'electric-quote-local-mode Ensure the following bindings: '((electric-quote-replace-double . t) (electric-quote-comment . t) (electric-quote-string . t)) Now press the key for: " The buffer's contents should become: |"foo \""| , and point should be at 7. ######################################################################### My proposal is that on a test failure, this generated doc-string should be output along with the other failure stuff. It doesn't actually add all that much bulk to the .log file. Here is patch which does this. If there are no objections, I will commit it in a day or two. 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). ------------=_1616615042-10761-1-- From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el 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 X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Michael Albinus , 47320-done@debbugs.gnu.org Received: via spool by 47320-done@debbugs.gnu.org id=D47320.161661666713925 (code D ref 47320); Wed, 24 Mar 2021 20:12:02 +0000 Received: (at 47320-done) by debbugs.gnu.org; 24 Mar 2021 20:11:07 +0000 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 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 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) MIME-Version: 1.0 References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> In-Reply-To: From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Date: Wed, 24 Mar 2021 20:10:48 +0000 Message-ID: Content-Type: multipart/alternative; boundary="000000000000bbc23705be4de5b2" X-Spam-Score: 0.0 (/) 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: -1.0 (-) --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-- From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Mar 2021 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Cc: Michael Albinus , 47320-done@debbugs.gnu.org Received: via spool by 47320-done@debbugs.gnu.org id=D47320.161667981729773 (code D ref 47320); Thu, 25 Mar 2021 13:44:02 +0000 Received: (at 47320-done) by debbugs.gnu.org; 25 Mar 2021 13:43:37 +0000 Received: from localhost ([127.0.0.1]:37535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPQGv-0007k9-3G for submit@debbugs.gnu.org; Thu, 25 Mar 2021 09:43:37 -0400 Received: from colin.muc.de ([193.149.48.1]:21402 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lPQGt-0007jk-0n for 47320-done@debbugs.gnu.org; Thu, 25 Mar 2021 09:43:35 -0400 Received: (qmail 50659 invoked by uid 3782); 25 Mar 2021 13:43:28 -0000 Received: from acm.muc.de (p4fe1524f.dip0.t-ipconnect.de [79.225.82.79]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 25 Mar 2021 14:43:27 +0100 Received: (qmail 6423 invoked by uid 1000); 25 Mar 2021 13:43:27 -0000 Date: Thu, 25 Mar 2021 13:43:27 +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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) 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: -1.0 (-) Hello, Jaćo. On Wed, Mar 24, 2021 at 20:10:48 +0000, Joćo Tįvora wrote: > > 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. The requests were only simple on the surface. Even though the original change took me around about an hour (it was at ~03-00 a.m. one sleepless night in 2019), I've spent a large part of two days trying to use the ert facilities without reading its source (they are essentially undocumented). I misunderstood your suggestion as suggesting outputting the doc-string using ert-fail. In the end I couldn't get that to work, as I said. > 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))))) OK, I see what you meant now. This version, instead of duplicating the test comparisons, duplicates the call to message. I think it boils down to ert (particularly its documentation) not being sufficiently advanced to do what we'd both like. But if you'd prefer your version, I'd be happy enough to commit it. I mainly just want finally to get the amendment off my hands and into master. [ .... ] > -- > Joćo Tįvora -- Alan Mackenzie (Nuremberg, Germany). From unknown Sun Aug 10 16:43:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47320: Improve failure reporting in test/lisp/electrict-tests.el 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: Thu, 25 Mar 2021 23:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47320 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Michael Albinus , 47320-done@debbugs.gnu.org Received: via spool by 47320-done@debbugs.gnu.org id=D47320.161671605126113 (code D ref 47320); Thu, 25 Mar 2021 23:48:01 +0000 Received: (at 47320-done) by debbugs.gnu.org; 25 Mar 2021 23:47:31 +0000 Received: from localhost ([127.0.0.1]:39908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPZhK-0006n7-T5 for submit@debbugs.gnu.org; Thu, 25 Mar 2021 19:47:31 -0400 Received: from mail-io1-f54.google.com ([209.85.166.54]:33763) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPZhI-0006mu-Lx for 47320-done@debbugs.gnu.org; Thu, 25 Mar 2021 19:47:29 -0400 Received: by mail-io1-f54.google.com with SMTP id n198so3713489iod.0 for <47320-done@debbugs.gnu.org>; Thu, 25 Mar 2021 16:47:28 -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=bns6MurV3TpCzemVZ6GGQ7Cl2NvlqGOSOZFJz9rfr1I=; b=TL1n8Gp/84FNNL3JAGWutDEPNsqUEeEI1/DAhUaeWPytOtLLIv2zEAQJSqCzQShtTt BNK2rTxhbfLcLctVwB+dsLqn5LnbCeCjU8P/+BrZ1n9raCv3ZXhg5paFHmQqgpqQ6WGl g4bMXax6IRADAZfh6r+bzEcq/pZaubYTsaHajEkw2Jl0Yg+ZNGzxZ10pF7ndJrSCjBPt OrLFZVWwhU5LaDp1Up9ZuL/557OtK0PevE0PI79HgX7lryF2+xLz1E89yxPLAZhFhVNk VH0u2gNQupFhSSZaLttz++3dLclfV2fTdhFfj+NLQH8Xpm7z7D5kIB2Wtv+5b5InTnDP NwQA== 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=bns6MurV3TpCzemVZ6GGQ7Cl2NvlqGOSOZFJz9rfr1I=; b=ob9zqs+YbuZcILLyCeh41rVhqZ5SqemuunTpbVhZKK/x2XronCmrp6YaQKKuhgXHQw S/snzXZ26MeaqPg7qoyAlRRQshOzFYX7XoxjnOfHujR/VQgLsFsxSzy+q5pG5ZQ3PPNJ ohFSWxiIs0HPgLJ2X1q0Jv/Q65/hL+OxDp8GepmQjy1V/d2GJF9fcD5D8LNodPgyR2BR I6cQ/KktiT9XzonYsIDzYRJdpW/FO3kM4ulCXijvyRTqVKGzR4yadZfTzKPWvy7QF77D RKqJxUKC7qbPKRjP7vbdco7k6d2GCZ+CXnfKGsIiNQ8fuKUDcQga375tEqti0w5/SWag xd+Q== X-Gm-Message-State: AOAM532E3jDjbDpg2noUlTKuQaEj+JczfQr4ZBNlnjUfI6QCytncgAWa YYkb5ubIgh+/M2jEzCxQMRVtLFvp2u0VunvLKL0= X-Google-Smtp-Source: ABdhPJy/cqvXWN6I2/bNDXkbPRrl0xmv81DtgpArvmfhRBkySOHwkYfbKT5o94JIqKux733aX77IwNVPGxaXELy43MM= X-Received: by 2002:a5e:8c16:: with SMTP id n22mr8273803ioj.156.1616716042853; Thu, 25 Mar 2021 16:47:22 -0700 (PDT) MIME-Version: 1.0 References: <87v99i5k0f.fsf@gmx.de> <877dlx3nb8.fsf@gmx.de> In-Reply-To: From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Date: Thu, 25 Mar 2021 23:47:11 +0000 Message-ID: Content-Type: multipart/alternative; boundary="0000000000006fe22c05be6509a9" X-Spam-Score: 0.0 (/) 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: -1.0 (-) --0000000000006fe22c05be6509a9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > > (point) expected-point))))) > > OK, I see what you meant now. This version, instead of duplicating the > test comparisons, duplicates the call to message. I The difference being that it's a one-arg call to message that has no branching, i.e. functional impact, so if that code gets out of sync, at least the test results don't change. Your version duplicates the test assertion itself. It's localized, and none of this is serious, I was just a bit peeved that my simple suggestion was ignored. The solution for this is to have ert.el utilize ert-describe-test and output that when the test fails. As you may know, ert-describe-test has the output you are looking for. Jo=C3=A3o --0000000000006fe22c05be6509a9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (point) expecte= d-point)))))

OK, I see what you meant now.=C2=A0 This version, instead of duplicating th= e
test comparisons, duplicates the call to message.=C2=A0 I
=
The difference being that it's a one-arg call to message= that has no
branching, i.e. functional impact, so if that c= ode gets out of sync,
at least the test results don't ch= ange.=C2=A0 Your version duplicates the
test assertion itself.

It's localized, and none of this is serious, I = was just a bit peeved
that my simple suggestion was ignored.= =C2=A0=C2=A0 The solution for this is to
have ert.el utilize= ert-describe-test and output that when
the test fails.=C2= =A0=C2=A0 As you may know, ert-describe-test has the output
= you are looking for.

Jo=C3=A3o

<= /div>


--0000000000006fe22c05be6509a9--