From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Newsgroups: gmane.emacs.bugs Subject: bug#51037: [PATCH] Make `print-level` & `print-length` customizable in ERT batch tests Date: Sun, 24 Oct 2021 12:50:35 -0700 Message-ID: <86mtmykxro.fsf@runbox.com> References: <86tuhvmtpl.fsf@runbox.com> <877deqec10.fsf@gnus.org> <83fste2u4i.fsf@gnu.org> <87ily94662.fsf@gnus.org> <83fstd1bth.fsf@gnu.org> <87czogslm4.fsf@gnus.org> <86ily2mjtq.fsf@runbox.com> <87r1cp89o4.fsf@gnus.org> <86fst5m48v.fsf@runbox.com> <87a6jd5891.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24582"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 28.0.50 Cc: gazally@runbox.com, 51037@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 24 21:51:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mejWS-000683-7u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 21:51:15 +0200 Original-Received: from localhost ([::1]:55428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mejWQ-0008NL-Eg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 15:51:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mejWI-0008LF-Ml for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 15:51:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mejWI-0003MP-DP for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 15:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mejWI-0002q5-BE for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 15:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Oct 2021 19:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51037 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51037-submit@debbugs.gnu.org id=B51037.163510505710903 (code B ref 51037); Sun, 24 Oct 2021 19:51:02 +0000 Original-Received: (at 51037) by debbugs.gnu.org; 24 Oct 2021 19:50:57 +0000 Original-Received: from localhost ([127.0.0.1]:41019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mejWD-0002pn-Fx for submit@debbugs.gnu.org; Sun, 24 Oct 2021 15:50:57 -0400 Original-Received: from aibo.runbox.com ([185.226.149.25]:41870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mejW8-0002pb-3L for 51037@debbugs.gnu.org; Sun, 24 Oct 2021 15:50:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Type:MIME-Version:Message-ID:Date:In-reply-to:Subject :Cc:To:From:References; bh=WP88wZZ7Obnl6O8DkV2Djv2zTZj4LeddbxrlKuwgDqk=; b=ff 1/zhyj4MDwqRIuM7Lk76GQ3GICIfn0y8fh2Y/YPxfQ6FgotNjoKV8BuWYzHQIFq1K2m7yYwrFK3uC zhdw39DCwUknsgjYUTNsi/L+2Ac+SqzssRuZ9MxNko0xCeInmFY0WOglVyGoXQD1IBpePIhHhf1FC WzZCU/y6yMSaUsS0X0uM5zRC8WoNoSXJFk3UWiJZBg1YMfl+u8n2b/aTMpoBhsdHUEFmh7vcPE/2H PKl5srdpU+Y4BS/aW+clBzYoJyZgGy4dtnbpaRv0nW88OFZ92Bl8txDfQWkGXOFAn6c4Llj0KYa8k VI4wyXFPmg6pM7MENV+Uf4ldaJNaWpRw==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1mejW0-0006Xo-Uo; Sun, 24 Oct 2021 21:50:45 +0200 Original-Received: by submission03.runbox with esmtpsa [Authenticated ID (942723)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1mejVu-0002QQ-Uo; Sun, 24 Oct 2021 21:50:39 +0200 In-reply-to: <87a6jd5891.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218192 Archived-At: +Gemini Lars Ingebrigtsen writes: > Michael writes: > >> Only when comparing _results_. Say I have test code like: >> >> (let ((a () >> (b ()))) >> ... >> (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 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