GNU bug report logs -
#66042
30.0.50; ERT test fails while trying to indent pretty-print
Previous Next
To reply to this bug, email your comments to 66042 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Sun, 17 Sep 2023 06:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Protesilaos Stavrou <info <at> protesilaos.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 17 Sep 2023 06:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Dear maintainers,
I have encountered a possible bug with an ERT test where it is trying to
perform indentation and fails with:
lisp-indent-initial-state: Wrong type argument: wholenump, -2
This is the test I am running:
(defun test-case (text pos expected)
(with-temp-buffer
(insert text)
(goto-char pos)
(backward-kill-word 1)
(should (string-equal (buffer-string) expected))))
(ert-deftest my-test ()
(test-case "aaa)))" 7 "aaa"))
Upon investigating further, I found that 'ert--pp-with-indentation-and-newline'
performs an 'indent-sexp'. When I comment that out and redefine the
function, the test no longer reports an indentation error with
wholenump. The test fails gracefully, as expected. Thus, the whole
file I am using is this:
(require 'ert)
(defun ert--pp-with-indentation-and-newline (object)
"Pretty-print OBJECT, indenting it to the current column of point.
Ensures a final newline is inserted."
(let ((begin (point))
(pp-escape-newlines t)
(print-escape-control-characters t))
(pp object (current-buffer))
(unless (bolp) (insert "\n"))
(save-excursion
(goto-char begin)
;; (indent-sexp)
)))
(defun test-case (text pos expected)
(with-temp-buffer
(insert text)
(goto-char pos)
(backward-kill-word 1)
(should (string-equal (buffer-string) expected))))
(ert-deftest my-test ()
(test-case "aaa)))" 7 "aaa"))
To be clear, my test should fail, but that is expected. I encountered
the ERT wholenump issue which prevented me from going further.
Is the indentation expected behaviour? Can we disable any/all
indentation of sexps within a test?
Thank you for your time,
Protesilaos (or simply "Prot")
--
Protesilaos Stavrou
https://protesilaos.com
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Sun, 17 Sep 2023 11:48:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 66042 <at> debbugs.gnu.org (full text, mbox):
Hi Prot,
Protesilaos Stavrou <info <at> protesilaos.com> writes:
> Dear maintainers,
>
> I have encountered a possible bug with an ERT test where it is trying to
> perform indentation and fails with:
>
> lisp-indent-initial-state: Wrong type argument: wholenump, -2
>
> This is the test I am running:
>
> (defun test-case (text pos expected)
> (with-temp-buffer
> (insert text)
> (goto-char pos)
> (backward-kill-word 1)
> (should (string-equal (buffer-string) expected))))
>
> (ert-deftest my-test ()
> (test-case "aaa)))" 7 "aaa"))
I tried to reproduce it on current master, but I couldn't. I ran the
test interactively, in case that makes a difference.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Sun, 17 Sep 2023 11:48:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 66042 <at> debbugs.gnu.org (full text, mbox):
Protesilaos Stavrou <info <at> protesilaos.com> writes:
> I have encountered a possible bug with an ERT test where it is trying to
> perform indentation and fails with:
>
> lisp-indent-initial-state: Wrong type argument: wholenump, -2
>
> This is the test I am running:
>
> (defun test-case (text pos expected)
> (with-temp-buffer
> (insert text)
> (goto-char pos)
> (backward-kill-word 1)
> (should (string-equal (buffer-string) expected))))
>
> (ert-deftest my-test ()
> (test-case "aaa)))" 7 "aaa"))
I can't reproduce this on current master. Evaluating the above two
forms in emacs -Q and then saying
M-x ert RET t RET
yields a new buffer "*ert*" containing
Selector: t
Passed: 0
Failed: 1 (1 unexpected)
Skipped: 0
Total: 1/1
Started at: 2023-09-17 13:44:28+0200
Finished.
Finished at: 2023-09-17 13:44:28+0200
F
F my-test
(ert-test-failed
((should (string-equal (buffer-string) expected)) :form
(string-equal "" "aaa") :value nil :explanation
(arrays-of-different-length 0 3 "" "aaa" first-mismatch-at 0)))
Which version of Emacs are you running?
Can you reproduce it in emacs -Q?
Added tag(s) unreproducible.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 17 Sep 2023 13:11:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Mon, 18 Sep 2023 04:56:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 66042 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello Stefan, Mauro,
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Sun, 17 Sep 2023 04:47:29 -0700
> [... 20 lines elided]
> I can't reproduce this on current master. Evaluating the above two
> forms in emacs -Q and then saying
> [... 23 lines elided]
> Which version of Emacs are you running?
>
> Can you reproduce it in emacs -Q?
Yes, I can reproduce it with 'emacs -Q' on Emacs trunk. I tried it just
now with the following code. See attached screenshot.
(require 'ert)
(defun ert--pp-with-indentation-and-newline (object)
"Pretty-print OBJECT, indenting it to the current column of point.
Ensures a final newline is inserted."
(let ((begin (point))
(pp-escape-newlines t)
(print-escape-control-characters t))
(pp object (current-buffer))
(unless (bolp) (insert "\n"))
(save-excursion
(goto-char begin)
(indent-sexp)
)))
(ert-deftest my-kill-backward-test-close-parens ()
"aaa)))"
(test-case "aaa)))" 7 "aaa"))
(defun test-case (text pos expected)
(with-temp-buffer
(insert text)
(goto-char pos)
(backward-kill-word 1)
(should (string-equal (buffer-string) expected))))
If I restart Emacs, comment out (indent-sexp), then evaluate the buffer,
and then the ERT test, everything works as expected. There is no
'wholenump' error.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
[2023-09-18_07:50:02_1274x1056.png (image/png, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Mon, 18 Sep 2023 09:31:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 66042 <at> debbugs.gnu.org (full text, mbox):
On 18/9/23 01:54, Protesilaos Stavrou wrote:
> Hello Stefan, Mauro,
>
>> From: Stefan Kangas <stefankangas <at> gmail.com>
>> Date: Sun, 17 Sep 2023 04:47:29 -0700
>
>> [... 20 lines elided]
>
>> I can't reproduce this on current master. Evaluating the above two
>> forms in emacs -Q and then saying
>
>> [... 23 lines elided]
>
>> Which version of Emacs are you running?
>>
>> Can you reproduce it in emacs -Q?
>
> Yes, I can reproduce it with 'emacs -Q' on Emacs trunk. I tried it just
> now with the following code. See attached screenshot.
>
> (require 'ert)
>
> (defun ert--pp-with-indentation-and-newline (object)
> "Pretty-print OBJECT, indenting it to the current column of point.
> Ensures a final newline is inserted."
> (let ((begin (point))
> (pp-escape-newlines t)
> (print-escape-control-characters t))
> (pp object (current-buffer))
> (unless (bolp) (insert "\n"))
> (save-excursion
> (goto-char begin)
> (indent-sexp)
> )))
>
> (ert-deftest my-kill-backward-test-close-parens ()
> "aaa)))"
> (test-case "aaa)))" 7 "aaa"))
>
> (defun test-case (text pos expected)
> (with-temp-buffer
> (insert text)
> (goto-char pos)
> (backward-kill-word 1)
> (should (string-equal (buffer-string) expected))))
>
I can reproduce it now. Your original recipe didn't include a docstring
for the ERT test.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66042
; Package
emacs
.
(Mon, 18 Sep 2023 09:36:02 GMT)
Full text and
rfc822 format available.
Removed tag(s) unreproducible.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 18 Sep 2023 22:51:01 GMT)
Full text and
rfc822 format available.
Added tag(s) confirmed.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 18 Sep 2023 22:51:01 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 270 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.