From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: fix/ert-multiline-explanation Date: Mon, 26 Oct 2015 08:55:12 +0000 Message-ID: <87h9lehuvj.fsf@russet.org.uk> References: <871tco2brx.fsf@russet.org.uk> <83a8r8wbcq.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445849752 25721 80.91.229.3 (26 Oct 2015 08:55:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Oct 2015 08:55:52 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 26 09:55:47 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZqdZC-00082t-V2 for ged-emacs-devel@m.gmane.org; Mon, 26 Oct 2015 09:55:47 +0100 Original-Received: from localhost ([::1]:51238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqdZC-0000x3-BR for ged-emacs-devel@m.gmane.org; Mon, 26 Oct 2015 04:55:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqdYk-0000tx-Q8 for emacs-devel@gnu.org; Mon, 26 Oct 2015 04:55:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqdYj-0006PS-M0 for emacs-devel@gnu.org; Mon, 26 Oct 2015 04:55:18 -0400 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:57696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqdYf-0006P4-N3; Mon, 26 Oct 2015 04:55:13 -0400 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot12.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1ZqdYf-0000Ma-AD; Mon, 26 Oct 2015 08:55:13 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1ZqdYf-0003TL-28; Mon, 26 Oct 2015 08:55:13 +0000 In-Reply-To: <83a8r8wbcq.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 24 Oct 2015 18:11:01 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192638 Archived-At: Eli Zaretskii writes: >> From: phillip.lord@russet.org.uk (Phillip Lord) >> Date: Wed, 21 Oct 2015 21:43:14 +0100 >> >> >> I would appreciate feedback on whether the change on >> fix/ert-multiline-explanation would be a good one. >> >> At the moment, ert allows you to attach explanation functions to explain >> why tests have failed. Unfortunately, these explanations are printed out >> using "pp" which escapes new lines. So multiline explanations are, >> largely, unreadable. >> >> So this patch ignores the value of pp-escape-newlines and resets it to >> nil for the duration. > > Could you please show an example, with and without the changes? Sure. The following code achieves the same thing with advice. (defun silly-predicate (x)) (defun silly-explainer (&rest args) (message "Silly predicate is silly. I mean, it's in the name, so why are you using it? It's never going to return a sensible answer. It is after silly. ^^^^^")) (put 'silly-predicate 'ert-explainer 'silly-explainer) (defun sisyphus--ert-pp-with-indentation-and-newline (orig object) (let ((pp-escape-newlines nil)) (funcall orig object))) (ert-deftest with () (should (silly-predicate (advice-add 'ert--pp-with-indentation-and-newline :around #'sisyphus--ert-pp-with-indentation-and-newline)))) (ert-deftest without () (should (silly-predicate (advice-remove 'ert--pp-with-indentation-and-newline #'sisyphus--ert-pp-with-indentation-and-newline)))) And the output. F with (ert-test-failed ((should (silly-predicate (advice-add 'ert--pp-with-indentation-and-newline :around #'sisyphus--ert-pp-with-indentation-and-newline))) :form (silly-predicate nil) :value nil :explanation "Silly predicate is silly. I mean, it's in the name, so why are you using it? It's never going to return a sensible answer. It is after silly. ^^^^^")) F without (ert-test-failed ((should (silly-predicate (advice-remove 'ert--pp-with-indentation-and-newline #'sisyphus--ert-pp-with-indentation-and-newline))) :form (silly-predicate nil) :value nil :explanation "Silly predicate is silly.\nI mean, it's in the name, so why are you using it?\nIt's never going to return a sensible answer.\nIt is after silly.\n ^^^^^")) The point is with the advice I can use multiline explainers, without it I can but it's pointless. The bug fix is not essential -- as I have shown I can advice around it, for this use case, I am struggling to see a use case for which "\n" is better than a newline. Phil