From: gerard.vermeulen@posteo.net
To: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] Patches for problems discovered with interactive testing
Date: Fri, 19 Jan 2024 09:48:59 +0000 [thread overview]
Message-ID: <7815c5360c35a1794db076a646518035@posteo.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 872 bytes --]
This patch addresses a number of glitches discovered during interactive
testing and contains possible fixes (sub-patch test-ob-maxima fixes
batch testing on my system, but not interactive testing).
The test-ob-maxima patch may be due to a different Maxima version, but
I do not think so. In batch testing test-ob-maxima passes contrary to
interactive mode.
The test-ob-python patch unsets org-src-preserve-indentation which I
have set.
The test-ob patch also unsets org-src-preserve-indentation.
The test-org-element patch indicates something weird on my system, I
want to report. Should not be applied.
The test-org patch also unsets org-src-preserve-indentation. This
reduces the number of failures to 2 while testing test-org
interactively.
Sorry to put them all together, but I do not know how to handle (ma)git
to keep the patches apart.
Regards -- Gerard
[-- Attachment #2: 0001-Patches-for-problems-discovered-with-interactive-tes.patch --]
[-- Type: application/octet-stream, Size: 13643 bytes --]
From 047d2eec7331845ef30462359af59ab61819bfc0 Mon Sep 17 00:00:00 2001
From: Gerard Vermeulen <gerard.vermeulen@posteo.net>
Date: Fri, 19 Jan 2024 09:15:26 +0100
Subject: [PATCH] Patches for problems discovered with interactive testing
The test-ob-maxima patch may be due to a different Maxima version, but
I do not think so. In batch testing test-ob-maxima passes contrary to
interactive mode.
The test-ob-python patch unsets org-src-preserve-indentation which I
have set.
The test-ob patch also unsets org-src-preserve-indentation.
The test-org-element patch indicates something weird on my system, I
want to report. Should not be applied.
The test-org patch also unsets org-src-preserve-indentation. This
reduces the number of failures to 2 while testing test-org
interactively.
---
testing/lisp/test-ob-maxima.el | 34 ++++++++++-------
testing/lisp/test-ob-python.el | 65 +++++++++++++++++---------------
testing/lisp/test-ob.el | 5 ++-
testing/lisp/test-org-element.el | 2 +-
testing/lisp/test-org.el | 19 ++++++----
5 files changed, 70 insertions(+), 55 deletions(-)
diff --git a/testing/lisp/test-ob-maxima.el b/testing/lisp/test-ob-maxima.el
index 653ed4041..c956c583b 100644
--- a/testing/lisp/test-ob-maxima.el
+++ b/testing/lisp/test-ob-maxima.el
@@ -26,37 +26,40 @@
"Test of integer input"
(org-test-at-id "b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8"
(org-babel-next-src-block)
- (should (equal 4 (org-babel-execute-src-block)))))
+ (should (equal '(("(linenum:0,") (4)) (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/string-input ()
"Test of string input"
(org-test-at-id "b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8"
(org-babel-next-src-block 2)
- (should (equal "- sin(x)" (org-babel-execute-src-block)))))
+ (should (equal '(("(linenum:0," "") ("-" "sin(x)"))
+ (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/simple-list-input ()
"Test of flat list input"
(org-test-at-id "b5561c6a-73cd-453a-ba5e-62ad84844de6"
(org-babel-next-src-block)
- (should (equal "[1, 2, 3] " (org-babel-execute-src-block)))))
+ (should (equal "(linenum:0,\n[1, 2, 3] " (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/list-input ()
"Test of list input"
(org-test-at-id "b5561c6a-73cd-453a-ba5e-62ad84844de6"
(org-babel-next-src-block 2)
- (should (equal "[2, [2, 3], 4] " (org-babel-execute-src-block)))))
+ (should (equal "(linenum:0,\n[2, [2, 3], 4] " (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/table-input1 ()
"Test of table input"
(org-test-at-id "400ee228-6b12-44fd-8097-7986f0f0db43"
(org-babel-next-src-block)
- (should (equal "[[2.0], [3.0]] " (org-babel-execute-src-block)))))
+ (should (equal "(linenum:0,\n[[2.0], [3.0]] "
+ (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/table-input2 ()
"Test of table input"
(org-test-at-id "400ee228-6b12-44fd-8097-7986f0f0db43"
(org-babel-next-src-block 2)
- (should (equal "[[2.0, 3.0]] " (org-babel-execute-src-block)))))
+ (should (equal "(linenum:0,\n[[2.0, 3.0]] "
+ (org-babel-execute-src-block)))))
(ert-deftest ob-maxima/matrix-output ()
"Test of table output"
@@ -64,7 +67,8 @@
(org-babel-next-src-block)
(should
(equal
- '((1 2 3) (2 3 4) (3 4 5)) (org-babel-execute-src-block)))))
+ '(("(linenum:0," "" "") (1 2 3) (2 3 4) (3 4 5))
+ (org-babel-execute-src-block)))))
;; 6 tests to test the :batch header argument
@@ -78,7 +82,7 @@ without labels."
integrate(exp(-t)*t^z, t, 0, inf));
#+end_src")
(should (equal (org-babel-execute-src-block)
- "(assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n gamma(z + 1)"))))
+ "(linenum:0,\n(assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n gamma(z + 1)"))))
(ert-deftest ob-maxima/batch+verbatim+quiet ()
"Exercise the `:batch' header argument.
@@ -90,8 +94,9 @@ labels."
(assume(z>0),
integrate(exp(-t)*t^z, t, 0, inf));
#+end_src")
- (should (equal (org-babel-execute-src-block)
- "(%i1) (assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n(%o1) gamma(z + 1)"))))
+ (should
+ (equal (org-babel-execute-src-block)
+ "(%i1) (linenum:0,\n(%i1) (assume(z > 0),integrate(exp(-t)*t^z,t,0,inf))\n(%o1) gamma(z + 1)"))))
(ert-deftest ob-maxima/batch+verbatim+:lisp ()
"Exercise the `:batch' header argument with `:lisp' reader.
@@ -103,7 +108,7 @@ Since `--quiet' is set, the output is printed (as a lisp form)."
#+end_src
")
(should (equal (org-babel-execute-src-block)
- "((%GAMMA SIMP) ((MPLUS SIMP) 1 $Z))"))))
+ "(%i1) (linenum:0,\n((%GAMMA SIMP) ((MPLUS SIMP) 1 $Z))"))))
(ert-deftest ob-maxima/batch+verbatim+empty-string-vq ()
"Exercise the `:batch' header argument with empty string input.
@@ -114,7 +119,7 @@ Since `--very-quiet' is set, the output is printed."
\"\";
#+end_src
")
- (should (equal (org-babel-execute-src-block) "\"\"\n "))))
+ (should (equal (org-babel-execute-src-block) "(linenum:0,\n\"\"\n "))))
(ert-deftest ob-maxima/batch+verbatim+empty-string ()
"Exercise the `:batch' header argument with empty string input.
@@ -126,7 +131,8 @@ labels."
\"\";
#+end_src
")
- (should (equal (org-babel-execute-src-block) "(%i1) \"\"\n(%o1) "))))
+ (should (equal (org-babel-execute-src-block)
+ "(%i1) (linenum:0,\n(%i1) \"\"\n(%o1) "))))
(ert-deftest ob-maxima/batch+verbatim+whitespace-string ()
"Exercise the `:batch' header argument with whitespace input.
@@ -139,7 +145,7 @@ labels."
#+end_src
")
(should (equal (org-babel-execute-src-block)
- "(%i1) \" \"\n(%o1) "))))
+ "(%i1) (linenum:0,\n(%i1) \" \"\n(%o1) "))))
(ert-deftest ob-maxima/batch+verbatim+syntax-error ()
"Exercise the `:batch' header argument with syntax error.
diff --git a/testing/lisp/test-ob-python.el b/testing/lisp/test-ob-python.el
index e3c6a4009..01eb90d49 100644
--- a/testing/lisp/test-ob-python.el
+++ b/testing/lisp/test-ob-python.el
@@ -41,9 +41,10 @@ return x
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-yes-header-argument-again ()
- (should
- (equal '(("a") hline ("b*") ("c*"))
- (org-test-with-temp-text "#+name: less-cols
+ (let ((org-src-preserve-indentation nil))
+ (should
+ (equal '(("a") hline ("b*") ("c*"))
+ (org-test-with-temp-text "#+name: less-cols
| a |
|---|
| b |
@@ -53,7 +54,7 @@ return x
<point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab]
#+end_src"
- (org-babel-execute-src-block)))))
+ (org-babel-execute-src-block))))))
(ert-deftest test-ob-python/colnames-nil-header-argument ()
(should
@@ -72,9 +73,10 @@ return x
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-no-header-argument-again ()
- (should
- (equal '(("a*") ("b*") ("c*"))
- (org-test-with-temp-text "#+name: less-cols
+ (let ((org-src-preserve-indentation nil))
+ (should
+ (equal '(("a*") ("b*") ("c*"))
+ (org-test-with-temp-text "#+name: less-cols
| a |
|---|
| b |
@@ -84,7 +86,7 @@ return x
<point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab]
#+end_src"
- (org-babel-execute-src-block)))))
+ (org-babel-execute-src-block))))))
(ert-deftest test-ob-python/colnames-no-header-argument ()
(should
@@ -106,9 +108,10 @@ return x
;; Disable the test on older Emacs as built-in python.el sometimes
;; fail to initialize session.
(skip-unless (version<= "28" emacs-version))
- (should
- (equal "20"
- (org-test-with-temp-text "#+begin_src python :session :results output
+ (let ((org-src-preserve-indentation nil))
+ (should
+ (equal "20"
+ (org-test-with-temp-text "#+begin_src python :session :results output
foo = 0
for _ in range(10):
foo += 1
@@ -117,30 +120,31 @@ return x
print(foo)
#+end_src"
- (org-babel-execute-src-block)))))
+ (org-babel-execute-src-block))))))
(ert-deftest test-ob-python/insert-necessary-blank-line-when-sending-code-to-interpreter ()
;; Disable the test on older Emacs as built-in python.el sometimes
;; fail to initialize session.
(skip-unless (version<= "28" emacs-version))
- (should
- (equal 2 (org-test-with-temp-text "#+begin_src python :session :results value
+ (let ((org-src-preserve-indentation nil))
+ (should
+ (equal 2 (org-test-with-temp-text "#+begin_src python :session :results value
if True:
1
2
#+end_src"
- ;; Previously, while adding `:session' to a normal code
- ;; block, also need to add extra blank lines to end
- ;; indent block or indicate logical sections. Now, the
- ;; `org-babel-python-evaluate-session' can do it
- ;; automatically:
- ;;
- ;; >>> if True:
- ;; >>> 1
- ;; >>> <insert_blank_line_here>
- ;; >>> 2
- (org-babel-execute-maybe)
- (org-babel-execute-src-block)))))
+ ;; Previously, while adding `:session' to a normal code
+ ;; block, also need to add extra blank lines to end
+ ;; indent block or indicate logical sections. Now, the
+ ;; `org-babel-python-evaluate-session' can do it
+ ;; automatically:
+ ;;
+ ;; >>> if True:
+ ;; >>> 1
+ ;; >>> <insert_blank_line_here>
+ ;; >>> 2
+ (org-babel-execute-maybe)
+ (org-babel-execute-src-block))))))
(ert-deftest test-ob-python/if-else-block ()
;; Disable the test on older Emacs as built-in python.el sometimes
@@ -161,9 +165,10 @@ value
;; Disable the test on older Emacs as built-in python.el sometimes
;; fail to initialize session.
(skip-unless (version<= "28" emacs-version))
- (should
- (equal 20
- (org-test-with-temp-text "#+begin_src python :session :results value
+ (let ((org-src-preserve-indentation nil))
+ (should
+ (equal 20
+ (org-test-with-temp-text "#+begin_src python :session :results value
foo = 0
for i in range(10):
foo += 1
@@ -172,7 +177,7 @@ value
foo
#+end_src"
- (org-babel-execute-src-block)))))
+ (org-babel-execute-src-block))))))
(ert-deftest test-ob-python/assign-underscore ()
;; Disable the test on older Emacs as built-in python.el sometimes
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 42c77ca56..e7d4b9671 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -663,10 +663,11 @@ duplicate results block."
(ert-deftest test-ob/partial-nested-code-block ()
"Test nested code blocks inside code blocks don't cause problems."
- (org-test-with-temp-text "#+begin_src org :results silent
+ (let ((org-src-preserve-indentation nil))
+ (org-test-with-temp-text "#+begin_src org :results silent
,#+begin_src emacs-lisp
#+end_src"
- (should (string= "#+begin_src emacs-lisp" (org-babel-execute-src-block)))))
+ (should (string= "#+begin_src emacs-lisp" (org-babel-execute-src-block))))))
(ert-deftest test-ob/does-not-replace-a-block-with-the-results ()
(org-test-with-temp-text "#+NAME: foo
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index ca7d77e28..f0958ff59 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -4457,7 +4457,7 @@ Text
'(paragraph nil " Two spaces\n\n \n Two spaces"))
'(paragraph nil "Two spaces\n\n\nTwo spaces")))
(should
- (equal
+ (equal ;; Fails in test. Why? (equal ...) form works in ielm.
'(paragraph nil " Two spaces\n" (verbatim nil "V") "\n Two spaces")
(org-element-normalize-contents
'(paragraph nil " Two spaces\n " (verbatim nil "V") "\n Two spaces"))))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 62d841b37..a50df601e 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -228,13 +228,15 @@ Otherwise, evaluate RESULT as an sexp and return its result."
(call-interactively #'org-comment-dwim)
(buffer-string)))))
;; In a source block, use appropriate syntax.
- (should
- (equal " ;; "
- (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n<point>\n#+END_SRC"
- (let ((org-edit-src-content-indentation 2))
- (call-interactively #'org-comment-dwim))
- (buffer-substring-no-properties (line-beginning-position)
- (point)))))
+ (let ((org-edit-src-content-indentation 2)
+ (org-src-preserve-indentation nil))
+ (should
+ (equal " ;; "
+ (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n<point>\n#+END_SRC"
+ (let ((org-edit-src-content-indentation 2))
+ (call-interactively #'org-comment-dwim))
+ (buffer-substring-no-properties (line-beginning-position)
+ (point))))))
(should
(equal "#+BEGIN_SRC emacs-lisp\n ;; a\n ;; b\n#+END_SRC"
(org-test-with-temp-text
@@ -242,7 +244,8 @@ Otherwise, evaluate RESULT as an sexp and return its result."
(transient-mark-mode 1)
(push-mark (point) t t)
(forward-line 2)
- (let ((org-edit-src-content-indentation 2))
+ (let ((org-edit-src-content-indentation 2)
+ (org-src-preserve-indentation nil))
(call-interactively #'org-comment-dwim))
(buffer-string)))))
--
2.42.0
next reply other threads:[~2024-01-19 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 9:48 gerard.vermeulen [this message]
2024-01-19 12:50 ` [PATCH] Patches for problems discovered with interactive testing Ihor Radchenko
2024-01-19 14:45 ` gerard.vermeulen
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=7815c5360c35a1794db076a646518035@posteo.net \
--to=gerard.vermeulen@posteo.net \
--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).