From: phillip.lord@russet.org.uk (Phillip Lord)
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: fix/ert-multiline-explanation
Date: Mon, 26 Oct 2015 08:55:12 +0000 [thread overview]
Message-ID: <87h9lehuvj.fsf@russet.org.uk> (raw)
In-Reply-To: <83a8r8wbcq.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 24 Oct 2015 18:11:01 +0300")
Eli Zaretskii <eliz@gnu.org> 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
next prev parent reply other threads:[~2015-10-26 8:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-21 20:43 fix/ert-multiline-explanation Phillip Lord
2015-10-21 20:47 ` fix/ert-multiline-explanation David Kastrup
2015-10-22 8:44 ` fix/ert-multiline-explanation Phillip Lord
2015-10-23 9:02 ` fix/ert-multiline-explanation Phillip Lord
2015-10-24 14:45 ` fix/ert-multiline-explanation David Engster
2015-10-26 8:52 ` fix/ert-multiline-explanation Phillip Lord
2015-10-24 15:11 ` fix/ert-multiline-explanation Eli Zaretskii
2015-10-26 8:55 ` Phillip Lord [this message]
2015-10-26 15:57 ` fix/ert-multiline-explanation Eli Zaretskii
2015-10-27 12:46 ` fix/ert-multiline-explanation Phillip Lord
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9lehuvj.fsf@russet.org.uk \
--to=phillip.lord@russet.org.uk \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.