[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fix/ert-multiline-explanation
From: |
Phillip Lord |
Subject: |
Re: fix/ert-multiline-explanation |
Date: |
Mon, 26 Oct 2015 08:55:12 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
>> From: address@hidden (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
Re: fix/ert-multiline-explanation, Eli Zaretskii, 2015/10/24
- Re: fix/ert-multiline-explanation,
Phillip Lord <=