Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-25 Thread Ihor Radchenko
Jens Schmidt  writes:

>> There is no universal rule when and when not to add trailing spaces in
>> the tests.
>
> Not sure what you mean by that, but some tests rely on trailing spaces
> and fail when these are not present.  An explicit test on that would
> make the issue more visible.  See below for what I mean.  The only (?)
> downside is that this catches such errors in test-org.el only, and not
> in all the other tests, many of which also contain (on purpose or
> inadvertently) trailing whitespace:

That's what I mean. For some tests, we do want trailing whitespace. For
some - not. Imagine that we decide to change the test failing due to
whitespace cleanup, but leave your proposed test. Then, your test may be
failing, and it will be rather difficult to figure out why.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Jens Schmidt
On 2023-08-24  14:24, Ihor Radchenko wrote:
> Jens Schmidt  writes:
> 
>> Would you mind if I added a test that explicitly and with some nice
>> error message tests for that condition?  I.e. if some unwary user
>> strips off trailing whitespace in test-org.el, that test would fail
>> with a reasonable message.
> 
> There is no universal rule when and when not to add trailing spaces in
> the tests.

Not sure what you mean by that, but some tests rely on trailing spaces
and fail when these are not present.  An explicit test on that would
make the issue more visible.  See below for what I mean.  The only (?)
downside is that this catches such errors in test-org.el only, and not
in all the other tests, many of which also contain (on purpose or
inadvertently) trailing whitespace:

[org-mode]$ grep -l $'[ \t]$' testing/lisp/*
testing/lisp/test-ob-C.el
testing/lisp/test-ob-R.el
testing/lisp/test-ob-fortran.el
testing/lisp/test-org-agenda.el
testing/lisp/test-org-element.el
testing/lisp/test-org-fold.el
testing/lisp/test-org-footnote.el
testing/lisp/test-org.el



diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index e33f500a3..e49c2f957 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -9363,6 +9363,16 @@ two
(string-match-p "\\`Invalid format.*%2" 
err-text))
 err)
 
+

+;;; Meta-test on Trailing Whitespace not Being Deleted
+
+(ert-deftest test-org/trailing-whitespace-deleted ()
+"Ensure trailing whitespace did not get deleted in this file."
+  (should
+   (equal "Do not delete trailing whitespace --> 
+   in this file."
+  "Do not delete trailing whitespace --> \n   in this file.")))
+
 (provide 'test-org)
 
 ;;; test-org.el ends here


If the blank after the arrow gets removed, this test fails as:


Test test-org/trailing-whitespace-deleted condition:
(ert-test-failed
 ((should
   (equal "Do not delete trailing whitespace -->
   in this file." "Do not delete trailing whitespace --> 
   in this file."))
  :form
  (equal "Do not delete trailing whitespace -->
   in this file." "Do not delete trailing whitespace --> 
   in this file.")
  :value nil :explanation
  (arrays-of-different-length 62 63 "Do not delete trailing whitespace -->
   in this file." "Do not delete trailing whitespace --> 
   in this file." first-mismatch-at 37)))
   FAILED  1068/1095  test-org/trailing-whitespace-deleted (0.000193 sec)

[...]

1 unexpected results:
   FAILED  test-org/trailing-whitespace-deleted





Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Ihor Radchenko
Ihor Radchenko  writes:

> What we can do is setting `delete-trailing-lines' to nil in tests - via
> directory-local variable.

Never mind. This will not affect deleting empty lines that are not
at the end of buffer.



Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Ihor Radchenko
Jens Schmidt  writes:

> Would you mind if I added a test that explicitly and with some nice
> error message tests for that condition?  I.e. if some unwary user
> strips off trailing whitespace in test-org.el, that test would fail
> with a reasonable message.

There is no universal rule when and when not to add trailing spaces in
the tests.

What we can do is setting `delete-trailing-lines' to nil in tests - via
directory-local variable.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Jens Schmidt
On 2023-08-24  13:41, Ihor Radchenko wrote:
> Jens Schmidt  writes:
> 
>> Seems the insert-heading-issue is still struggling, this time during
>> a "make check" @ d5ee33fed8dd80d3f9f9811d86a73827fde80780 using Emacs 29:
>> ...
>>FAILED   998/1094  test-org/insert-heading (0.018306 sec) at 
>> ../lisp/test-org.el:1845
> 
> I cannot reproduce on my system. Using Emacs 29.
> Our CI tests are also not failing.

Not a bug, my bad:  I keep forgetting about `delete-trailing-whitespace'
on my `before-save-hook'.

Would you mind if I added a test that explicitly and with some nice
error message tests for that condition?  I.e. if some unwary user
strips off trailing whitespace in test-org.el, that test would fail
with a reasonable message.




Re: [BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Ihor Radchenko
Jens Schmidt  writes:

> Seems the insert-heading-issue is still struggling, this time during
> a "make check" @ d5ee33fed8dd80d3f9f9811d86a73827fde80780 using Emacs 29:
> ...
>FAILED   998/1094  test-org/insert-heading (0.018306 sec) at 
> ../lisp/test-org.el:1845

I cannot reproduce on my system. Using Emacs 29.
Our CI tests are also not failing.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[BUG] "make check" reports a failure on test-org/insert-heading @ d5ee33f (this time with Emacs 29)

2023-08-24 Thread Jens Schmidt
Seems the insert-heading-issue is still struggling, this time during
a "make check" @ d5ee33fed8dd80d3f9f9811d86a73827fde80780 using Emacs 29:

Test test-org/insert-heading condition:
(ert-test-failed
 ((should
   (equal "* 1\n** 1.1\n** 1.2\n*\n* 2"
  (org-test-with-temp-text "* 1\n** 1.1\n** 1.2\n* 2" ... 
...)))
  :form
  (equal "* 1\n** 1.1\n** 1.2\n*\n* 2"
 #("* 1\n** 1.1\n** 1.2\n* \n* 2" 0 2
   (face org-level-1)
   2 3
   (face org-level-1)
   4 5
   (face org-level-2)
   5 7
   (face org-level-2)
   7 10
   (face org-level-2)
   11 12
   (face org-level-2)
   12 14
   (face org-level-2)
   14 17
   (face org-level-2)
   21 23
   (face org-level-1)
   23 24
   (face org-level-1)))
  :value nil :explanation
  (arrays-of-different-length 23 24 "* 1\n** 1.1\n** 1.2\n*\n* 2"
  #("* 1\n** 1.1\n** 1.2\n* \n* 2" 0 2
(face org-level-1)
2 3
(face org-level-1)
4 5
(face org-level-2)
5 7
(face org-level-2)
7 10
(face org-level-2)
11 12
(face org-level-2)
12 14
(face org-level-2)
14 17
(face org-level-2)
21 23
(face org-level-1)
23 24
(face org-level-1))
  first-mismatch-at 19)))
   FAILED   998/1094  test-org/insert-heading (0.018306 sec) at 
../lisp/test-org.el:1845