emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix test-org-element/cache
Date: Sat, 15 May 2021 19:38:34 +0800	[thread overview]
Message-ID: <87wns0jkg5.fsf@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 1285 bytes --]

Hi,

I encountered a bug in test-org-element/cache. The test creates the
following Org file with table and runs (org-element-at-point) at the
beginning of the second line. The expectation in the test is that we are
at the table row, while in reality these are two distinct tables (the
"ab" line is a table within "item" list entry):

#+begin_center
P0

- item

  P1
  | a | b |
| c | d |
#+end_center

I tested with emacs -Q (with no org-element-cache enabled). The return
value of (org-element-at-point) is (table (...)). In the test (before
inserting "item") the same point has different element:

#+begin_center
P0



  P1
  | a | b |
| c | d |
#+end_center

Now, org-element-at-point (correctly) returns (table-row (...)).

The master version of the test assumed that element would not change
after modification (wrong). Yet, the test was passing with
org-element-use-cache enabled (it should have not been).

The current patch is fixing the test. Though I am not sure if it should
be applied right now. The correct test will fail and org-element also
need to be fixed. I do have a fix for org-element, but it is quite
complex, not fully ready yet, involves other features, and needs to be
discussed carefully. So, I am only submitting the patch for the test for
now.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-test-org-element-cache-Preserve-local-structures.patch --]
[-- Type: text/x-diff, Size: 1403 bytes --]

From b9da1e2c4faeb5545fb43641209dd6eca80f5d51 Mon Sep 17 00:00:00 2001
Message-Id: <b9da1e2c4faeb5545fb43641209dd6eca80f5d51.1621077736.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 15 May 2021 19:19:09 +0800
Subject: [PATCH] Fix test-org-element/cache "Preserve local structures when
 re-parenting."

* testing/lisp/test-org-element.el (test-org-element/cache): Add
spaces to make the "abcd" table a single table.  The old version uses
example org text with two tables and was passing because of another
bug in org-element-cache.  Testing the old version with
org-element-use-cache set to nil would yield error, while it should
not.
---
 testing/lisp/test-org-element.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 4f108754c..28e9ecd12 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -3770,7 +3770,7 @@ (ert-deftest test-org-element/cache ()
    (eq 'table
        (let ((org-element-use-cache t))
 	 (org-test-with-temp-text
-	     "#+begin_center\nP0\n\n<point>\n\n  P1\n  | a | b |\n| c | d |\n#+end_center"
+	     "#+begin_center\nP0\n\n<point>\n\n  P1\n  | a | b |\n  | c | d |\n#+end_center"
 	   (save-excursion (search-forward "| c |") (org-element-at-point))
 	   (insert "- item")
 	   (search-forward "| c |")
-- 
2.26.3


             reply	other threads:[~2021-05-15 11:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 11:38 Ihor Radchenko [this message]
2021-05-15 11:51 ` [PATCH] Fix test-org-element/cache Bastien
2021-05-15 12:31   ` Ihor Radchenko
2021-05-15 12:34     ` Bastien
2021-05-15 12:04 ` Nicolas Goaziou
2021-05-15 12:21   ` Ihor Radchenko
2021-05-15 12:33     ` 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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87wns0jkg5.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).