unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22471: ert batch should print compile parsable error messages
@ 2016-01-27  9:15 Phillip Lord
  2016-01-27 16:06 ` Eli Zaretskii
  2020-08-20 16:39 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 12+ messages in thread
From: Phillip Lord @ 2016-01-27  9:15 UTC (permalink / raw)
  To: 22471


Currently, when running in batch, ert prints out messages like so:


Running 24 tests (2016-01-27 09:05:17+0000)
   passed   1/24  buffer-string=
   passed   2/24  buffer=
...
   passed  22/24  sisyphus-test-with-find-file
   passed  23/24  to-string
   passed  24/24  with-temp-buffers

Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)

1 unexpected results:
   FAILED  crash-out

It would be nice to add some compilation-mode parsable data to this. So,
something like


   passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)

It would also be nice to add colourisation: red and green for passed and
failed. In the idea world, these could be added as ansi colour codes to
the batch output of ERT. They should work on the command line then also.

More of an RFE than a bug, but it is odd that compilation mode works
with lots and lots of test frameworks, but not Emacs'

Phil





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2016-01-27  9:15 bug#22471: ert batch should print compile parsable error messages Phillip Lord
@ 2016-01-27 16:06 ` Eli Zaretskii
  2016-01-27 21:53   ` Phillip Lord
  2020-08-20 16:39 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2016-01-27 16:06 UTC (permalink / raw)
  To: Phillip Lord; +Cc: 22471

> From: phillip.lord@russet.org.uk (Phillip Lord)
> Date: Wed, 27 Jan 2016 09:15:44 +0000
> 
> 
> Currently, when running in batch, ert prints out messages like so:
> 
> 
> Running 24 tests (2016-01-27 09:05:17+0000)
>    passed   1/24  buffer-string=
>    passed   2/24  buffer=
> ...
>    passed  22/24  sisyphus-test-with-find-file
>    passed  23/24  to-string
>    passed  24/24  with-temp-buffers
> 
> Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)
> 
> 1 unexpected results:
>    FAILED  crash-out
> 
> It would be nice to add some compilation-mode parsable data to this. So,
> something like
> 
> 
>    passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)

FWIW, I have never seen a test suite that displayed in
compilation-mode compatible format.  If we do that (and I'm
necessarily opposed to that), we'd be the odd one out, I think.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2016-01-27 16:06 ` Eli Zaretskii
@ 2016-01-27 21:53   ` Phillip Lord
  2016-01-28  1:28     ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Phillip Lord @ 2016-01-27 21:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 22471

Eli Zaretskii <eliz@gnu.org> writes:

>> From: phillip.lord@russet.org.uk (Phillip Lord)
>> Date: Wed, 27 Jan 2016 09:15:44 +0000
>> 
>> 
>> Currently, when running in batch, ert prints out messages like so:
>> 
>> 
>> Running 24 tests (2016-01-27 09:05:17+0000)
>>    passed   1/24  buffer-string=
>>    passed   2/24  buffer=
>> ...
>>    passed  22/24  sisyphus-test-with-find-file
>>    passed  23/24  to-string
>>    passed  24/24  with-temp-buffers
>> 
>> Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)
>> 
>> 1 unexpected results:
>>    FAILED  crash-out
>> 
>> It would be nice to add some compilation-mode parsable data to this. So,
>> something like
>> 
>> 
>>    passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)
>
> FWIW, I have never seen a test suite that displayed in
> compilation-mode compatible format.  If we do that (and I'm
> necessarily opposed to that), we'd be the odd one out, I think.

There's a couple in the compilation mode regexp -- cucumber, ruby and
perl test harnesses and so forth.

I put a quick attempt at this up on feature/parsable-ert-output.

   passed  22/24  sisyphus-test-with-find-file at test/sisyphus-test.el line 277.
   passed  23/24  to-string at test/sisyphus-test.el line 96.
   passed  24/24  with-temp-buffers at test/sisyphus-test.el line 232.

Works, but makes for rather a cluttered output.

Thoughts welcome.

Phil





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2016-01-27 21:53   ` Phillip Lord
@ 2016-01-28  1:28     ` Glenn Morris
  2016-01-28 17:14       ` Phillip Lord
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2016-01-28  1:28 UTC (permalink / raw)
  To: Phillip Lord; +Cc: 22471


Why would you call the batch version of ert from within Emacs,
when M-x ert exists and does colour, hyperlinking to source, etc?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2016-01-28  1:28     ` Glenn Morris
@ 2016-01-28 17:14       ` Phillip Lord
  0 siblings, 0 replies; 12+ messages in thread
From: Phillip Lord @ 2016-01-28 17:14 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 22471

Glenn Morris <rgm@gnu.org> writes:

> Why would you call the batch version of ert from within Emacs,
> when M-x ert exists and does colour, hyperlinking to source, etc?

M-x ert is nice, but has one main failure. It's not running in a clean,
controllable Emacs; it's running in my Emacs. I use M-x ert only when I
am debugging failing tests.

The rest of the time, I run tests in a clean, newly launched Emacs with
a sandboxed .emacs.d/elpa. As a secondary advantage, it can be easier to
test two or three Emacs versions at the same time.

I've been writing a library to help get around this problem, but
fundamentally, the only clean way to test code is not to run it in the
same Emacs as is launching it. At some point, I'd like to add the
ability to launch an emacs for every test.

Phil






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2016-01-27  9:15 bug#22471: ert batch should print compile parsable error messages Phillip Lord
  2016-01-27 16:06 ` Eli Zaretskii
@ 2020-08-20 16:39 ` Lars Ingebrigtsen
  2020-08-20 16:51   ` Philipp Stephani
  2021-10-23  0:15   ` Stefan Kangas
  1 sibling, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-20 16:39 UTC (permalink / raw)
  To: Phillip Lord; +Cc: 22471

phillip.lord@russet.org.uk (Phillip Lord) writes:

> Currently, when running in batch, ert prints out messages like so:
>
> Running 24 tests (2016-01-27 09:05:17+0000)
>    passed   1/24  buffer-string=
>    passed   2/24  buffer=
> ...
>    passed  22/24  sisyphus-test-with-find-file
>    passed  23/24  to-string
>    passed  24/24  with-temp-buffers
>
> Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)
>
> 1 unexpected results:
>    FAILED  crash-out
>
> It would be nice to add some compilation-mode parsable data to this. So,
> something like
>
>    passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)

I think that would look rather cluttered for the "passed" lines, but it
would indeed be helpful on the FAILED lines.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2020-08-20 16:39 ` Lars Ingebrigtsen
@ 2020-08-20 16:51   ` Philipp Stephani
  2021-10-23  0:15   ` Stefan Kangas
  1 sibling, 0 replies; 12+ messages in thread
From: Philipp Stephani @ 2020-08-20 16:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 22471, Phillip Lord

Am Do., 20. Aug. 2020 um 18:41 Uhr schrieb Lars Ingebrigtsen <larsi@gnus.org>:
>
> phillip.lord@russet.org.uk (Phillip Lord) writes:
>
> > Currently, when running in batch, ert prints out messages like so:
> >
> > Running 24 tests (2016-01-27 09:05:17+0000)
> >    passed   1/24  buffer-string=
> >    passed   2/24  buffer=
> > ...
> >    passed  22/24  sisyphus-test-with-find-file
> >    passed  23/24  to-string
> >    passed  24/24  with-temp-buffers
> >
> > Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)
> >
> > 1 unexpected results:
> >    FAILED  crash-out
> >
> > It would be nice to add some compilation-mode parsable data to this. So,
> > something like
> >
> >    passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)
>
> I think that would look rather cluttered for the "passed" lines, but it
> would indeed be helpful on the FAILED lines.
>

I'm doing something similar in my Bazel ruleset for Elisp
(https://github.com/phst/rules_elisp/blob/0b24aa1660af2f6c668899bdd78aaba383d7ac18/elisp/ert/runner.el#L446).
It would be nice to have an API for this as my code needs a few hacks
and subtleties.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2020-08-20 16:39 ` Lars Ingebrigtsen
  2020-08-20 16:51   ` Philipp Stephani
@ 2021-10-23  0:15   ` Stefan Kangas
  2021-10-24 12:57     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2021-10-23  0:15 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 22471, Phillip Lord

[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> phillip.lord@russet.org.uk (Phillip Lord) writes:
>
>> Currently, when running in batch, ert prints out messages like so:
>>
>> Running 24 tests (2016-01-27 09:05:17+0000)
>>    passed   1/24  buffer-string=
>>    passed   2/24  buffer=
>> ...
>>    passed  22/24  sisyphus-test-with-find-file
>>    passed  23/24  to-string
>>    passed  24/24  with-temp-buffers
>>
>> Ran 24 tests, 23 results as expected, 1 unexpected (2016-01-27 09:05:18+0000)
>>
>> 1 unexpected results:
>>    FAILED  crash-out
>>
>> It would be nice to add some compilation-mode parsable data to this. So,
>> something like
>>
>>    passed   1/24  buffer-string=  (in ./test.sisyphus-test.el:22:)
>
> I think that would look rather cluttered for the "passed" lines, but it
> would indeed be helpful on the FAILED lines.

This would in my opinion be very useful and a great timesaver.  But yes,
for FAILED results only, much like how the compiler only gives us line
numbers if there is a problem.  (AFAIR, that's how the test frameworks
I've used do it.)

So I updated the patch from the feature/parsable-ert-output against
current master (patch attached), made sure that one of our tests failed,
and then tested it with "make check".

I got the following backtrace, but gave up after looking at it for a
while:

Debugger entered--Lisp error: (error "Don’t know where
‘fns-tests-string-bytes’ is defin...")
  signal(error ("Don’t know where ‘fns-tests-string-bytes’ is defin..."))
  error("Don't know where `%s' is defined" fns-tests-string-bytes)
  find-function-search-for-symbol(fns-tests-string-bytes ert-deftest nil)
  find-definition-noselect(fns-tests-string-bytes ert-deftest)
  ert-test-location([...])
[...]

[-- Attachment #2: 0001-Add-source-information-to-ERT-batch-mode.patch --]
[-- Type: text/x-diff, Size: 2569 bytes --]

From e6c185f280e2c330825beebad7d2393c21199564 Mon Sep 17 00:00:00 2001
From: Phillip Lord <phillip.lord@russet.org.uk>
Date: Wed, 27 Jan 2016 20:59:50 +0000
Subject: [PATCH] Add source information to ERT batch mode

* lisp/emacs-lisp/ert.el (ert-test-location): New function.
(ert-run-tests-batch): Add test location to failed tests.  (Bug#22471)
---
 lisp/emacs-lisp/ert.el | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 57655403c2..36f5062e83 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1353,6 +1353,23 @@ ert--insert-infos
 (defvar ert-quiet nil
   "Non-nil makes ERT only print important information in batch mode.")
 
+(defun ert-test-location (test)
+  "Return a string description the source location of TEST."
+  (let* ((loc
+          (find-definition-noselect (ert-test-name test) 'ert-deftest))
+         (buffer
+          (car loc))
+         (point (cdr loc))
+         (file
+          (file-relative-name
+           (buffer-file-name buffer)))
+         (line (with-current-buffer buffer
+                 (line-number-at-pos point))))
+    (format "at %s line %s." file line)))
+
+(defvar ert-batch-backtrace-right-margin 70
+  "The maximum line length for printing backtraces in `ert-run-tests-batch'.")
+
 ;;;###autoload
 (defun ert-run-tests-batch (&optional selector)
   "Run the tests specified by SELECTOR, printing results to the terminal.
@@ -1471,14 +1488,17 @@ ert-run-tests-batch
             (let* ((max (prin1-to-string (length (ert--stats-tests stats))))
                    (format-string (concat "%9s  %"
                                           (prin1-to-string (length max))
-                                          "s/" max "  %S (%f sec)")))
+                                          "s/" max "  %S (%f sec)%s")))
               (message format-string
                        (ert-string-for-test-result result
                                                    (ert-test-result-expected-p
                                                     test result))
                        (1+ (ert--stats-test-pos stats test))
                        (ert-test-name test)
-                       (ert-test-result-duration result))))))))
+                       (ert-test-result-duration result)
+                       (if (ert-test-result-expected-p test result)
+                           ""
+                         (concat " " (ert-test-location test))))))))))
    nil))
 
 ;;;###autoload
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2021-10-23  0:15   ` Stefan Kangas
@ 2021-10-24 12:57     ` Lars Ingebrigtsen
  2021-10-24 14:27       ` Stefan Kangas
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-10-24 12:57 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 22471, Phillip Lord

Stefan Kangas <stefan@marxist.se> writes:

> I got the following backtrace, but gave up after looking at it for a
> while:
>
> Debugger entered--Lisp error: (error "Don’t know where
> ‘fns-tests-string-bytes’ is defin...")
>   signal(error ("Don’t know where ‘fns-tests-string-bytes’ is defin..."))

Well -- ert-deftest doesn't record what file it's from, I think?
Looking at the definition, it just adds the test to the symbol-plist.
So that macro would also have to stash the file name somewhere.
load-history would be possible (but sounds unclean), so stashing it in
the symbol-plist would be better.

Then find-definition-noselect could be extended to use that for this
type.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2021-10-24 12:57     ` Lars Ingebrigtsen
@ 2021-10-24 14:27       ` Stefan Kangas
  2021-10-24 20:01         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2021-10-24 14:27 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 22471, Phillip Lord

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Well -- ert-deftest doesn't record what file it's from, I think?
> Looking at the definition, it just adds the test to the symbol-plist.
> So that macro would also have to stash the file name somewhere.
> load-history would be possible (but sounds unclean), so stashing it in
> the symbol-plist would be better.
>
> Then find-definition-noselect could be extended to use that for this
> type.

Right, I'm just wondering what has changed as presumably the patch
worked when Phillip Lord first wrote it?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2021-10-24 14:27       ` Stefan Kangas
@ 2021-10-24 20:01         ` Lars Ingebrigtsen
  2022-01-24 12:54           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-10-24 20:01 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 22471, Phillip Lord

Stefan Kangas <stefan@marxist.se> writes:

> Right, I'm just wondering what has changed as presumably the patch
> worked when Phillip Lord first wrote it?

Oh, I interpreted the branch as a sketch towards a solution but I see
that he posted apparent output from it, too:

> I put a quick attempt at this up on feature/parsable-ert-output.
> 
>    passed 22/24 sisyphus-test-with-find-file at test/sisyphus-test.el
> line 277.
>    passed  23/24  to-string at test/sisyphus-test.el line 96.
>    passed  24/24  with-temp-buffers at test/sisyphus-test.el line 232.

So it worked at one point?  (I'm not able to compile that branch at
all -- it segfaults while bootstrapping.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#22471: ert batch should print compile parsable error messages
  2021-10-24 20:01         ` Lars Ingebrigtsen
@ 2022-01-24 12:54           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 12:54 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 22471, Phillip Lord

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> Right, I'm just wondering what has changed as presumably the patch
>> worked when Phillip Lord first wrote it?
>
> Oh, I interpreted the branch as a sketch towards a solution but I see
> that he posted apparent output from it, too:

I've now fixed up the patch and am pushing to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-01-24 12:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27  9:15 bug#22471: ert batch should print compile parsable error messages Phillip Lord
2016-01-27 16:06 ` Eli Zaretskii
2016-01-27 21:53   ` Phillip Lord
2016-01-28  1:28     ` Glenn Morris
2016-01-28 17:14       ` Phillip Lord
2020-08-20 16:39 ` Lars Ingebrigtsen
2020-08-20 16:51   ` Philipp Stephani
2021-10-23  0:15   ` Stefan Kangas
2021-10-24 12:57     ` Lars Ingebrigtsen
2021-10-24 14:27       ` Stefan Kangas
2021-10-24 20:01         ` Lars Ingebrigtsen
2022-01-24 12:54           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).