all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sebastian Miele <iota@whxvd.name>
To: Eli Zaretskii <eliz@gnu.org>
Cc: yantar92@posteo.net, 65734@debbugs.gnu.org
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	[thread overview]
Message-ID: <87il8fbj8q.fsf@whxvd.name> (raw)
In-Reply-To: <8334zmrmnu.fsf@gnu.org>

> From: Eli Zaretskii <eliz@gnu.org>
> Date: Sun, 2023-09-10 19:57 +0300
>
>> From: Sebastian Miele <iota@whxvd.name>
>> Cc: Eli Zaretskii <eliz@gnu.org>, Ihor Radchenko <yantar92@posteo.net>
>> Date: Sun, 10 Sep 2023 18:31:20 +0200
>> 
>> I removed emacs-orgmode@gnu.org from CC.
>> 
>> > From: Sebastian Miele <iota@whxvd.name>
>> > 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" "A<POINT>B" "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<POINT>" "1" "2" ""))
      (subtest 1 '("AB" "") '("-2" "-1" "AB" "<POINT>1" "2" ""))
      (subtest 2 '("AB" "1" "") '("-2" "-1" "AB" "1" "<POINT>2" ""))
      (subtest 3 '("AB" "1" "2" "") '("-2" "-1" "AB" "1" "2" "<POINT>"))
      (subtest 9 '("AB" "1" "2" "") '("-2" "-1" "AB" "1" "2" "<POINT>"))
      (subtest -1 '("" "AB") '("-2" "-1<POINT>" "AB" "1" "2" ""))
      (subtest -2 '("" "-1" "AB") '("-2<POINT>" "-1" "AB" "1" "2" ""))
      (subtest -3 '("-2" "-1" "AB") '("<POINT>-2" "-1" "AB" "1" "2" ""))
      (subtest -9 '("-2" "-1" "AB") '("<POINT>-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.





  reply	other threads:[~2023-09-12 13:04 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 16:30 [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/)] Sebastian Miele
2023-09-05 10:29 ` Ihor Radchenko
2023-09-05 10:29   ` bug#65734: " Ihor Radchenko
2023-09-05 11:54   ` Eli Zaretskii
2023-09-05 11:54     ` Eli Zaretskii
2023-09-05 15:25     ` Sebastian Miele
2023-09-05 15:25     ` Sebastian Miele
2023-09-05 15:50       ` Eli Zaretskii
2023-09-05 15:50       ` Eli Zaretskii
2023-09-06  8:23         ` Ihor Radchenko
2023-09-06  8:23           ` Ihor Radchenko
2023-09-06 12:16           ` Eli Zaretskii
2023-09-06 13:30             ` Sebastian Miele
2023-09-06 13:30             ` Sebastian Miele
2023-09-07 13:49               ` Ihor Radchenko
2023-09-07 13:49                 ` Ihor Radchenko
2023-09-10 16:31               ` Sebastian Miele
2023-09-10 16:57                 ` Eli Zaretskii
2023-09-12 13:04                   ` Sebastian Miele [this message]
2023-09-12 14:09                     ` Eli Zaretskii
2023-12-25 18:53                   ` Sebastian Miele
2024-01-06  8:58                     ` Eli Zaretskii
2024-06-19 14:01                       ` Ihor Radchenko
2024-06-19 14:50                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22  9:00                         ` Eli Zaretskii
2024-06-22  9:51                           ` Eli Zaretskii
2024-06-23 19:26                             ` bug#65734: 29.1.50; kill-whole-line and visibility of Org subtrees Andrea Corallo
2024-06-22 19:00                           ` 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/)] Stefan Kangas
2024-06-27  8:41                             ` Eli Zaretskii
2023-12-04 12:42                 ` Ihor Radchenko
2023-12-04 23:20                   ` Sebastian Miele
2023-09-06 12:16           ` Eli Zaretskii
2023-09-06  8:30     ` Ihor Radchenko
2023-09-06  8:30       ` Ihor Radchenko
2023-09-06 12:20       ` Eli Zaretskii
2023-09-06 12:20         ` Eli Zaretskii
2023-09-07 10:00         ` Ihor Radchenko
2023-09-07 10:00         ` Ihor Radchenko
2023-09-07 10:19           ` Eli Zaretskii
2023-09-07 10:27             ` Sebastian Miele
2023-09-07 10:27             ` Sebastian Miele
2023-09-07 13:43             ` Ihor Radchenko
2023-09-07 13:43             ` Ihor Radchenko
2023-09-07 10:19           ` Eli Zaretskii
2023-09-06 15:04       ` Sebastian Miele
2023-09-06 15:04       ` Sebastian Miele
2023-09-07 10:03         ` Ihor Radchenko
2023-09-07 10:03         ` Ihor Radchenko
2023-09-05 14:30   ` Max Nikulin
2023-09-05 14:30   ` Max Nikulin
2023-09-05 15:42     ` Eli Zaretskii
2023-09-05 15:42       ` Eli Zaretskii
2023-09-05 15:50       ` Ihor Radchenko
2023-09-05 15:50       ` Ihor Radchenko
2023-09-05 16:02         ` Max Nikulin
2023-09-05 16:02           ` Max Nikulin
2023-09-05 16:12           ` Ihor Radchenko
2023-09-05 16:12             ` Ihor Radchenko
2023-09-05 16:14         ` Eli Zaretskii
2023-09-05 16:14         ` Eli Zaretskii
2024-01-07 16:27         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-07 16:27           ` Stefan Monnier
2024-01-08 12:15           ` Ihor Radchenko
2024-01-08 12:15             ` Ihor Radchenko
2024-01-08 15:33             ` Stefan Monnier
2024-01-09 14:52               ` Ihor Radchenko
2024-01-09 14:52               ` Ihor Radchenko
2024-01-09 16:48                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-09 16:48                   ` Stefan Monnier
2024-01-09 22:21                   ` Ihor Radchenko
2024-01-09 22:21                   ` Ihor Radchenko
2024-01-08 15:33             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-09 15:47             ` Ihor Radchenko
2024-01-09 15:47               ` Ihor Radchenko
2024-01-09 16:01               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-09 16:01                 ` Stefan Monnier
2024-01-09 22:33                 ` Ihor Radchenko
2024-01-09 22:33                 ` Ihor Radchenko
2024-01-10  3:08                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10  3:08                     ` Stefan Monnier
2024-01-10 12:52                   ` Eli Zaretskii
2024-01-10 12:52                   ` Eli Zaretskii
2024-01-10 13:05                     ` Ihor Radchenko
2024-01-10 13:55                       ` Eli Zaretskii
2024-01-11 15:50                         ` Ihor Radchenko
2024-01-11 15:50                         ` Ihor Radchenko
2024-01-11 16:05                           ` Eli Zaretskii
2024-01-11 16:05                           ` Eli Zaretskii
2024-01-11 16:15                             ` Ihor Radchenko
2024-01-11 16:44                               ` Eli Zaretskii
2024-01-11 16:44                               ` Eli Zaretskii
2024-01-11 18:08                                 ` Ihor Radchenko
2024-01-11 18:08                                 ` Ihor Radchenko
2024-01-11 19:19                                   ` Eli Zaretskii
2024-01-12 12:24                                     ` Ihor Radchenko
2024-01-12 12:24                                       ` Ihor Radchenko
2024-01-12 12:32                                       ` Eli Zaretskii
2024-01-12 12:32                                       ` Eli Zaretskii
2024-01-12 12:39                                         ` Ihor Radchenko
2024-01-12 14:03                                           ` Eli Zaretskii
2024-01-12 14:03                                             ` Eli Zaretskii
2024-01-12 14:15                                             ` Ihor Radchenko
2024-01-12 14:15                                             ` Ihor Radchenko
2024-01-12 12:39                                         ` Ihor Radchenko
2024-01-11 19:19                                   ` Eli Zaretskii
2024-01-12 21:09                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-12 21:09                                     ` Stefan Monnier
2024-01-12 21:16                                     ` Ihor Radchenko
2024-01-12 21:16                                     ` Ihor Radchenko
2024-01-11 16:15                             ` Ihor Radchenko
2024-01-10 13:55                       ` Eli Zaretskii
2024-01-10 16:26                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10 16:26                       ` Stefan Monnier
2024-01-10 16:39                         ` Eli Zaretskii
2024-01-10 16:39                           ` Eli Zaretskii
2024-01-11 15:44                         ` Ihor Radchenko
2024-01-11 15:44                           ` Ihor Radchenko
2024-01-10 13:05                     ` Ihor Radchenko
2024-01-09 15:50 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il8fbj8q.fsf@whxvd.name \
    --to=iota@whxvd.name \
    --cc=65734@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.