From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: Some testing issues Date: Sat, 08 Jul 2017 16:50:28 +0200 Message-ID: <87zicfnft7.fsf@rosalinde> References: <8737a8j61r.fsf@rosalinde> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499525457 28626 195.159.176.226 (8 Jul 2017 14:50:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Jul 2017 14:50:57 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: Emacs developers To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 08 16:50:52 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTr4M-00075n-GV for ged-emacs-devel@m.gmane.org; Sat, 08 Jul 2017 16:50:50 +0200 Original-Received: from localhost ([::1]:33115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTr4R-0002UY-Ri for ged-emacs-devel@m.gmane.org; Sat, 08 Jul 2017 10:50:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTr4L-0002UP-Ml for emacs-devel@gnu.org; Sat, 08 Jul 2017 10:50:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTr4I-00024R-HV for emacs-devel@gnu.org; Sat, 08 Jul 2017 10:50:49 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:65291) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTr4I-0001wi-63 for emacs-devel@gnu.org; Sat, 08 Jul 2017 10:50:46 -0400 Original-Received: from rosalinde ([83.135.5.146]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LvPgd-1ddExy3HFL-010eEv; Sat, 08 Jul 2017 16:50:30 +0200 In-Reply-To: (Noam Postavsky's message of "Sat, 8 Jul 2017 00:20:23 -0400") X-Provags-ID: V03:K0:UdJNBKX+oCWtL1oMT34k1P09EG3H6Pk6GPd0NwL6BerFwVaOAbp TvjLDoW6OHBgtQyrSeXPoxgrt7ymV72gypn/NOKNeILP5q7K+/k2CvRfVzDky+3zp36G1v1 pMKI8SQssueREafXxDgWVv9pswfKdUr8/iohj6DaIg4hB0uPQWo893xxOOasDdgzgNHB20B 2d5OToBjyoCiWBQ+aj82g== X-UI-Out-Filterresults: notjunk:1;V01:K0:Q0KPGF9+rIQ=:pmjc9ioZy3WaLKaWgLLTyL g7SWh7CMrX/mrgd9hWLldCbAsodTp/LkItbw4xT3/ZRoleMqmwSjlALUnMz1xR2uHSJkwX61s mQmK7cUjfX5d98vF2SVX/BaOvx8fuvtpy6c12Je5OJbMr84bMQSR8AW1Lbg4r557SMGu+i/S+ wwxBew/rRSrwghKq3G5BqaFh8QbVip7To6sOSSiw2aoCUTtIxCAn2oVYzMFindlovc87nmIPN RWwGysL9p2m5lY59BlRWY56xqa4HdnDnYqyL0TJxjwHS/QkecMF81QE9kPrCfbDdVP8NOyHQ2 kbgtBuD4nHKtuz5K5jBHpMX5Tx921YJuUbAuS2tJn9G+2xRAUQwysDWxf6Uu36wxgWFEm03HT EBeU0b5d6jBUI53pWAHwYzQKyC+tF4jOoNGTJQvY1db+XbQ7bAQStAX4cWMIn8f4G35gZCevP 2ZqFYjZqZxqmWxapyOERd0RHEkv6mZRGE+npEraGdeUrMf6i9qv3XODlkYHiWkNCinItpxE8i aMIes6xx28WK4ttc3Nx4nCM4JLdds4UzLfwVkWY3VtIc5IWSdTkP69Phu122JnfmHVU327x38 ADTtFl7uebvJ7SMZrrOPaqMQGGiLtuTWEU4k1i9/eudcb4IiE7xb8p2/j7056BpyTn5dsmrwV zbjw/L313+En6K27RWyytstiFbUo8TTnV61x7g5cVboAET1AyvKZHQS7a8LT1Tp+9dvxL319R 12bDQ2x3m/suAmmEfkBM9fqJRaz60R/I8oeST93arM429pifRYoXZ80G6v1L2lSDz9YCE3Q0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216326 Archived-At: On Sat, 8 Jul 2017 00:20:23 -0400 Noam Postavsky wrote: > On Fri, Jul 7, 2017 at 5:22 PM, Stephen Berman wrote: >> Several of the tests call the function todo-toggle-view-done-items, >> which contains this code: >> >> (if (not (pos-visible-in-window-p shown)) >> (recenter) >> >> (`shown' stores the position of the first done item in the category, if >> it is shown.) When using todo-mode and also when stepping through the >> function with Edebug, it works as expected. > > If I comment out the set-window-buffer call it fails for me in Edebug > as well (when running the first time). You're right, I must have misrembered or been thinking of a different case; sorry. > By the way, in order to run successfully I did also need the following > patch, otherwise all the tests failed (I think it only happens for me > because I'm running from an Emacs that's living under my home > directory). > > modified test/lisp/calendar/todo-mode-tests.el > @@ -46,6 +46,7 @@ (defmacro with-todo-test (&rest body) > "Set up an isolated todo-mode test environment." > (declare (debug (body))) > `(let* ((todo-test-home (make-temp-file "todo-test-home-" t)) > + (abbreviated-home-dir nil) > (process-environment (cons (format "HOME=%s" todo-test-home) > process-environment)) > (todo-directory todo-test-data-dir) The only test file that sets abbreviated-home-dir is package-test.el, in the macro with-package-test, which was indeed the inspiration for with-todo-test. I assume this would only effect cases like yours, and hence make the test environment more robust, or are possible problems that setting it to nil could raise? >> But when running the tests, >> sometimes -- but not always -- it fails with the error "`recenter'ing a >> window that does not display current-buffer." In those cases, the test >> failure is prevented by evaluating the following sexp immediately before >> calling todo-toggle-view-done-items: >> >> (set-window-buffer nil (current-buffer)) >> >> When using todo-mode this is not necessary, because the selected window >> always contains the current buffer when the function is called, but >> apparently when running the tests, this isn't always the case, although >> according to Edebug it is, AFAICT. > > When I evaluate (selected-window) in edebug before the call, I see > that the selected window is showing the *ert* buffer. Yes, I should have checked again before posting that. >> And again, the failure only happens >> in some cases, though in those, it is reliably reproducible. In >> addition, in at least one case, when I rerun the test immediately after >> it fails, then it succeeds. > > I think it succeeds the second time because the *ert* buffer is in a > different state. What state is that? In Edebug it appears to be the same as on the first test run: current-buffer is todo-test-1.todo and selected-window is the one showing the *ert* buffer, yet now (pos-visible-in-window-p shown) is non-nil, while on the first run it is nil. I don't see what makes the difference -- certainly not the value of the variable `shown', which is 226 and that position in window displaying *ert* is visible in both runs. >> And lastly, in one case, the test succeeds >> without the set-window-buffer call when run interactively, but fails >> without it when run in batch mode from the shell. Any idea what's going >> on here? (If anyone wants to take a closer look, comments in the test >> file point out the problematic cases.) > > todo-test-toggle-item-header04? I added a `message' call, and it seems > that in batch mode the selected window shows *scratch* whereas in > interactive mode it shows *ert*. I would say the success in > interactive mode is just a coincidence. Well, it's a reliably reproducible coincidence, which seems like a contradiction in terms. >> A second problem concerns trying to reference a message in a test. The >> function todo-toggle-view-done-items outputs a message if the category >> contains no done items, and the test captures this by calling >> current-message immediately after todo-toggle-view-done-items. This >> works when running the test interactively, but in a batch run, >> current-message is nil (though the message is output in the shell). >> Why? > > I think it's simply that there is no echo-area or any concept of a > "current" message when running in batch mode. Yes, as Martin also pointed out; I didn't realize (or stop to think about) that. > lread-tests--last-message might be worth looking at: > > (defun lread-tests--last-message () > (with-current-buffer "*Messages*" > (save-excursion > (goto-char (point-max)) > (skip-chars-backward "\n") > (buffer-substring (line-beginning-position) (point))))) Thanks for the pointer, and for the feedback. Steve Berman