From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sebastian Miele Newsgroups: gmane.emacs.bugs Subject: bug#65734: [BUG] kill-whole-line on folded subtrees [9.6.8 (release_9.6.8-3-g21171d @ /home/w/usr/emacs/0/29/0/lisp/org/)] Date: Tue, 12 Sep 2023 15:04:41 +0200 Message-ID: <87il8fbj8q.fsf@whxvd.name> References: <87il8pao4l.fsf@whxvd.name> <87tts8vrpb.fsf@localhost> <83h6o84yz1.fsf@gnu.org> <875y4oaban.fsf@whxvd.name> <83bkeg4o1u.fsf@gnu.org> <87o7ifu2v8.fsf@localhost> <838r9j339x.fsf@gnu.org> <87tts78lve.fsf@whxvd.name> <87zg1u0yrp.fsf@whxvd.name> <8334zmrmnu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31362"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yantar92@posteo.net, 65734@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 12 15:47:06 2023 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 1qg3jL-0007iq-4R for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Sep 2023 15:47:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg3gO-0005lR-Ip; Tue, 12 Sep 2023 09:44:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg3gL-0005kV-RC for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 09:43:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg3gL-0003Xr-J9 for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 09:43:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qg3gQ-0005MB-6r for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 09:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sebastian Miele Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Sep 2023 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65734 X-GNU-PR-Package: emacs Original-Received: via spool by 65734-submit@debbugs.gnu.org id=B65734.169452618620493 (code B ref 65734); Tue, 12 Sep 2023 13:44:02 +0000 Original-Received: (at 65734) by debbugs.gnu.org; 12 Sep 2023 13:43:06 +0000 Original-Received: from localhost ([127.0.0.1]:56535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qg3fV-0005KS-Jv for submit@debbugs.gnu.org; Tue, 12 Sep 2023 09:43:06 -0400 Original-Received: from mout-p-102.mailbox.org ([80.241.56.152]:52428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qg3fR-0005Ju-IQ for 65734@debbugs.gnu.org; Tue, 12 Sep 2023 09:43:04 -0400 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4RlPsg5sgfz9sWm; Tue, 12 Sep 2023 15:42:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whxvd.name; s=MBO0001; t=1694526167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0o5418bRf0U97mT3nhyLUDQWH444KHXZmSXd+xn+5Do=; b=YlludN0/M4Fug4kmYmC6At9Qev9/oASlsyA4iPbSuSmNVCl1cYtB1eA9n0CF4VuY3E2o4Y Gn35u+UAd/FjwQrkqdOkDPwIVPN6t6inYW/nlzVo4zxGhVPIkS2MB2FLHXO+/n+6NMxQ+s NgKPYLEwFGt4HeUvkWYijkEv7Q8Ni/MpoCTnS0PzqduCDOEVRwzm6rq0Fpc/DwjQ0YVI1C Erq5buwMdIYmFqGbqHIuG0RWMAbDnAx84xPIZlDEnpZGsNqrDLaI2NLfz/yRHpeYFqGDMZ fVcfBa3pw+k5Y8i5aZgkMo+LpCpedyqLYdifLSCluJz+aDi2V1J1q7URsnMKmA== In-reply-to: <8334zmrmnu.fsf@gnu.org> X-Rspamd-Queue-Id: 4RlPsg5sgfz9sWm 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270168 Archived-At: > From: Eli Zaretskii > Date: Sun, 2023-09-10 19:57 +0300 > >> From: Sebastian Miele >> Cc: Eli Zaretskii , Ihor Radchenko >> Date: Sun, 10 Sep 2023 18:31:20 +0200 >> >> I removed emacs-orgmode@gnu.org from CC. >> >> > From: Sebastian Miele >> > Date: Wed, 2023-09-06 15:30 +0200 >> > >> > I will write the tests. And I will probably come up with an updated >> > version of the original patch. There is at least one cosmetic change. >> > And something else that I want to have tried. May take some time. >> >> Please have a look at the following patch. For now it contains three >> tests, two of them with :expected-result :failed. (They do not fail on >> the bug-fixed version of `kill-whole-line'.) > > Yes, there should be more tests, ideally: there are situations where > kill-whole-line signals an error, Those tests are on the radar. > and I don't think I see tests where some of the text is invisible (as > the function uses forward-visible-line and end-of-visual-line). That already is covered via (org-mode) and (org-fold-hide-sublevels 1) in test `kill-whole-line-invisible'. >> There probably will be more tests and further questions. But for now, I >> would like to basically have a statement of whether the style of writing >> the tests goes in an acceptable direction. > > Looks reasonable, but I'm not sure I understand what will the test > show if one of the tests fails: will the information shown then tell > enough to understand which of the sub-tests failed and why? That almost certainly would not be immediately obvious in the current state. I have next to no experience in working with testing frameworks. But I assumed that regressions do not happen that often, and that it would be good enough if the code of the test can be grasped quickly. Then, in case of a regression, the test code can be temporarily sprinkled with some printf-like debugging to find out the exact location in the test. However, enough of that printf-like debugging could also be hard-coded, like in the following definition (see the line ending in the comment "Provide some context"): (ert-deftest kill-whole-line-read-only () ;;:expected-result :failed (cl-flet ((subtest (kill-whole-line-arg expected-kill-lines expected-buffer-lines) (should `(subtest ,kill-whole-line-arg)) ; Provide some context (ert-with-test-buffer-selected nil (simple-tests--set-buffer-text-point-mark (string-join '("-2" "-1" "AB" "1" "2" "") "\n")) (ert-simulate-command '(read-only-mode 1)) (should-error (ert-simulate-command `(kill-whole-line ,kill-whole-line-arg)) :type 'buffer-read-only) (should (equal (string-join expected-kill-lines "\n") (car kill-ring))) (should (equal (string-join expected-buffer-lines "\n") (simple-tests--get-buffer-text-point-mark)))))) (subtest 0 '("AB") '("-2" "-1" "AB" "1" "2" "")) (subtest 1 '("AB" "") '("-2" "-1" "AB" "1" "2" "")) (subtest 2 '("AB" "1" "") '("-2" "-1" "AB" "1" "2" "")) (subtest 3 '("AB" "1" "2" "") '("-2" "-1" "AB" "1" "2" "")) (subtest 9 '("AB" "1" "2" "") '("-2" "-1" "AB" "1" "2" "")) (subtest -1 '("" "AB") '("-2" "-1" "AB" "1" "2" "")) (subtest -2 '("" "-1" "AB") '("-2" "-1" "AB" "1" "2" "")) (subtest -3 '("-2" "-1" "AB") '("-2" "-1" "AB" "1" "2" "")) (subtest -9 '("-2" "-1" "AB") '("-2" "-1" "AB" "1" "2" "")))) With the always succeeding (should `(subtest ,kill-whole-line-arg)) ; Provide some context at the beginning of ervery subtest, the context would be clear after pressing l in a buffer showing the ERT test results (but never on the console). An alternative would be to use `message'. That would also provide the context on the console. However, that also may be a bit noisy. Another possibility would be to define every subtest as a top-level test, by a macro like: (defmacro simple-test--define-kill-whole-line-read-only-test (kill-whole-line-arg) ...) But that feels a bit over the top and unflexible. What to me feels like an ideal solution would be the concept of a current context during an ERT test. Just something like a (defvar ert-current-context) that always initially is dynamically let-bound to nil during a test. That could be setq'ed at different locations in a test to different arbitrary values (somewhat like ERT explanations). When a should fails, and the ert-current-context is non-nil, ERT would display the current context as the first information on the failed test. WDYT? For now I assume that providing context via (should `(subtest ,kill-whole-line-arg)) ; Provide some context is good enough.