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: Mon, 15 Nov 2021 15:11:54 -0800 Message-ID: <864k8dm2th.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> <86mtmykxro.fsf@runbox.com> <87y26hz24c.fsf@gnus.org> <86bl3blcgm.fsf@runbox.com> <87wnlya9sj.fsf@gnus.org> <86wnlbmooj.fsf@runbox.com> <83bl2nw723.fsf@gnu.org> <86tugen3q4.fsf@runbox.com> <83lf1qtxzw.fsf@gnu.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="34670"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 28.0.50 Cc: gazally@runbox.com, larsi@gnus.org, 51037@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 16 00:13:17 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 1mmlA4-0008qO-8V for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 00:13:16 +0100 Original-Received: from localhost ([::1]:41912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmlA2-0003IU-FA for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Nov 2021 18:13:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mml9r-0003I3-Rk for bug-gnu-emacs@gnu.org; Mon, 15 Nov 2021 18:13:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mml9q-0007Fx-F6 for bug-gnu-emacs@gnu.org; Mon, 15 Nov 2021 18:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mml9q-0004wl-2A for bug-gnu-emacs@gnu.org; Mon, 15 Nov 2021 18:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Nov 2021 23:13: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.163701794218959 (code B ref 51037); Mon, 15 Nov 2021 23:13:02 +0000 Original-Received: (at 51037) by debbugs.gnu.org; 15 Nov 2021 23:12:22 +0000 Original-Received: from localhost ([127.0.0.1]:56511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mml9B-0004vj-K8 for submit@debbugs.gnu.org; Mon, 15 Nov 2021 18:12:21 -0500 Original-Received: from transit01.runbox.com ([91.220.196.211]:46714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mml96-0004vP-8V for 51037@debbugs.gnu.org; Mon, 15 Nov 2021 18:12:19 -0500 Original-Received: from aibo.runbox.com ([185.226.149.25]) by transit01.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1mml8y-00AJ5U-GT; Tue, 16 Nov 2021 00:12:08 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Type:MIME-Version:Message-ID:Date:In-reply-to:Subject :Cc:To:From:References; bh=4ihKTHCGFF6igsF/FJxKuKlxY4HnFpJys/1El998aro=; b=Kh aPAcXGph1P99x8pDZE/6Upp078gCC46jSswDsbh0GhTEVgFblRiawcLok/FlE4NrXPIB/yuuBycxs tsdjIK/h0chjnu0Mews/2qcqmeOa8dSH9lLNo7csO7VGFPYBgzB9LIJgiV84ePSEEOLLdcdfVhqyb HnbHsiIgm4Ez46LTAN95evXrIzprb78cnm0I3feuqB+A1o3p9gDPysQU5lU/YIRNrLBI0WzdATPl0 7PZQ3YLo4KuR1QPoOHRpqDNPAiV8UL40gB3PzZ71C2Q4Mi7n8jtZyuilYPm0oWLxXWbVvPH8BCzqU 0yfKvdRec3NEgIZHg6lc1FzySrbuSPjg==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1mml8x-0004zR-JP; Tue, 16 Nov 2021 00:12:07 +0100 Original-Received: by submission03.runbox with esmtpsa [Authenticated ID (942723)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1mml8o-0000jG-Hx; Tue, 16 Nov 2021 00:11:58 +0100 In-reply-to: <83lf1qtxzw.fsf@gnu.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:220086 Archived-At: Eli Zaretskii writes: >> From: Michael >> Cc: larsi@gnus.org, gazally@runbox.com, 51037@debbugs.gnu.org >> Date: Sun, 14 Nov 2021 07:42:27 -0800 >> >> This commit introduces three new ert variables: >> ert-batch-print-length, ert-batch-print-level & >> ert-batch-backtrace-length. The first two control print-length > ^^ > Please leave 2 spaces between sentences, per our coding > conventions > (here and elsewhere in your patch). Fixed. >> +line lengths (i.e. to get full backtraces), or a positive >> integer to > > Either "i.e.," (with a comma), or "i.e.@:". Otherwise TeX will > typeset "i.e." as if it ends a sentence. Fixed. >> +** New ERT batch variables >> + >> +Add three variables 'ert-batch-print-length', >> 'ert-batch-print-level' > > In NEWS we use a different style, like this: > > Three new variables 'ert-batch-print-length', ... > > IOW, "Add" is not appropriate here. Kindly fixed already by Lars. >> Backtrace mode will attempt to abbreviate printing of >> backtrace >> -frames to make them shorter than this, but success is not >> -guaranteed. If set to nil or zero, Backtrace mode will not >> -abbreviate the forms it prints." >> +frames by setting `print-level' & `print-length' to make them > > Please don't use "&" in doc strings; use "and" instead (here and > elsewhere in the patch). Fixed. >> +shorter than this, but success is not guaranteed. If set to >> nil >> +or zero, Backtrace mode will not abbreviate the forms it >> prints." > ^^^^^^^^^ > "backtrace", not capitalized/ Oh! Good catch -- fixed. >> -(defun ert--setup-results-buffer (stats listener buffer-name) >> +(defvar ert--output-buffer-name "*ert*") >> + >> +(defun ert--setup-results-buffer (stats listener) >> "Set up a test results buffer. >> >> -STATS is the stats object; LISTENER is the results listener; >> -BUFFER-NAME, if non-nil, is the buffer name to use." >> - (unless buffer-name (setq buffer-name "*ert*")) >> - (let ((buffer (get-buffer-create buffer-name))) >> +STATS is the stats object; LISTENER is the results listener." >> + (let ((buffer (get-buffer-create ert--output-buffer-name))) > > Why this change in the signature of the function? A consequence of a decision discussed elsewhere in this thread: the only reason that parameter existed was to enable unit testing, which I re-wrote to use `cl-letf`. Background: prior to this patch, `ert-run-tests-interactively` accepted two optional parameters: output-buffer-name and message-fn. The were soley used for the purpose of unit testing, and were even documented in commentary as such: ;; Should OUTPUT-BUFFER-NAME and MESSAGE-FN really be arguments here? ;; They are needed only for our automated self-tests at the moment. ;; Or should there be some other mechanism? I carried over the idiom to ert-run-tests-batch when adding my own unit tests. Lars pointed out that I could use `cl-letf` to override the function definition of `message`, rather than using a "test-only" parameter. I did that, then removed the test-only parameters from `ert-run-tests-interactively` an re-wrote those unit tests to also use `cl-letf`. At that point, there was no one using the the `buffer-name` parameter to `ert--setup-results-buffer`. Since it's an internal function, I felt comfortable just removing the parameter. -- Michael