bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51037: [PATCH] Make `print-level` & `print-length` customizable in E


From: Michael
Subject: bug#51037: [PATCH] Make `print-level` & `print-length` customizable in ERT batch tests
Date: Sun, 24 Oct 2021 12:50:35 -0700
User-agent: mu4e 1.4.15; emacs 28.0.50

+Gemini

Lars Ingebrigtsen <larsi@gnus.org> writes:

Michael <sp1ff@runbox.com> writes:

Only when comparing _results_. Say I have test code like:

   (let ((a (<some complex list>)
         (b (<another complex list>))))
     ...
     (should (equal a b))

My changes would case the error message from the failed `should`
invocation to print `a` & `b` more fully (i.e. with fewwer
ellipses).

Ah, I see.

The backtrace logic is separate, and un-touched by my patch as
submitted (tho of course I can change that).

Perhaps it would be better if the same variables affected both result
printing and backtraces in the code that ert is testing.

I've run down a bit of a rabbit hole on this.

The issue: stack traces are printed by the `backtrace`
package. backtrace.el was authored by Gemini (which is why I've
added him to this thread). backtrace.el doesn't directly work in
terms of `print-le{ngth,vel}`: it defines a custom variable
`backtrace-line-length` and then adjusts print-level &
print-length in let bindings in order to:

 1. try to respect the desired line length
 2. not trigger bug 31919 (Lisp Debugger doesn't work when at
 stack limit)

Bug 31919 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31919>
occurs when the debugger is invoked in response to
`max-lisp-eval-depth` being exceeded. Since we're close the the
top of the stack already, a too-high setting of `print-level`
will cause backtraces to break.

Because of this arrangement, any attempt on the part of ert to
customize print-length & print-level comes to nothing--
`backtrace` will adjust them to satisfy conditions 1 & 2 above.

For myself, I was quite surprised to all learn this: I had to
spend a fair bit of time digging through the source to find out
what was happening to my settings for print-length &
print-level.

My personal incliniation is to remove the `backtrace-line-length`
variable entirely, and make the `debug` package responsible for
controlling print-level so as to avoid 31919. But that's me: is
there a compelling use-case for backtrace.el working in terms of
limiting line length rather than just using `print-le{ve,ength}`?

--
Michael <sp1ff@runbox.com>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]