Clean up and simplify the "Testing Org" section

This commit is contained in:
Gerard Vermeulen 2024-05-16 11:47:20 +02:00
parent 3d55a73be0
commit 352f0f2698

View File

@ -3693,8 +3693,9 @@ variable
:END:
Listing [[lst:batch-org-testing]] shows the recommended way: use =make test= in a
clean Org git repository. Listing [[lst:setup-org-mode-test-1]] and
[[lst:setup-org-mode-test-2]] provide facilities for [[https://orgmode.org/worg/org-tests/index.html][Testing Org]] interactively.
clean Org git repository. In addition, on my weird Darwin system, I do =ln -sf
VCS/org-mode/lisp= and =ln -sf VCS/org-mode/testing= to fix the command =make
repro=.
#+caption[Batch Org testing]:
#+caption: Batch Org testing: obligatory before mailing a patch.
@ -3703,96 +3704,6 @@ clean Org git repository. Listing [[lst:setup-org-mode-test-1]] and
make test > out.txt 2>&1
#+end_src
#+caption[Testing Org facilities 1]:
#+caption: Testing Org facilities 1: for use during development only.
#+name: lst:setup-org-mode-test-1
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'emacs
(defvar org-testing-dir nil)
(defvar org-testing-lisp-files nil)
(defun setup-org-mode-test ()
"Initialize an `org-mode' test."
(interactive)
(unless (and org-testing-dir org-testing-lisp-files)
(find-library "org.el")
(quit-window)
(setq org-testing-dir
(file-name-concat
(file-name-directory
(directory-file-name
(file-name-directory
(buffer-file-name (get-buffer "org.el")))))
(file-name-as-directory "testing")))
(setq org-testing-lisp-files
(seq-filter
(lambda (f)
(string-suffix-p ".el" f))
(directory-files
(file-name-concat org-testing-dir
(file-name-as-directory "lisp"))))))
(unless (fboundp 'org-test-with-temp-text)
(find-file (file-name-concat org-testing-dir "org-test.el"))
(eval-buffer)
(quit-window))
(let* ((test
(completing-read "Org-mode test: "
org-testing-lisp-files nil 'require-match)))
(find-file (file-name-concat
org-testing-dir (file-name-as-directory "lisp") test))
(eval-buffer)
(message "Evaluated '%s'"
(file-name-nondirectory (buffer-file-name (get-buffer test))))
(quit-window))))
#+end_src
#+caption[Testing Org facilities 2]:
#+caption: Testing Org facilities 2: for use during development only.
#+name: lst:setup-org-mode-test-2
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'emacs
;; Stolen from `org-test-run-all-tests'.
(defun org-test-run-some-tests ()
"Run some defined tests.
Load all test files first."
(interactive)
(org-test-touch-all-examples)
(org-test-update-id-locations)
(org-test-load)
(let (;; Catch errors in diary sexps better.
(calendar-debug-sexp t))
;; test-org-element/normalize-contents fails (can't fix).
;; test-ob-exp/noweb-on-export fails due to spacing (can't fix).
;; test-ob-exp/noweb-on-export-with-exports-results due to spacing (idem).
;; ob-python hangs sometimes, but seldom.
;; ob-tangle/continued-code-blocks-w-noweb-ref fails.
(ert (rx (or "org/" "org-fold" "org-element" "org-macro" "org-src"
"property-inheritance"
"ob/" "ob-emacs-lisp" "ob-eshell"
"ob-python" "ob-tangle")))
(org-test-kill-all-examples)))
(defun org-test-run-ob-tests ()
"Run all \"ob\" tests.
Load all test files first."
(interactive)
(org-test-load)
(let (;; Catch errors in diary sexps better.
(calendar-debug-sexp t))
(ert "ob/")))
(defun org-test-run-a-test-file ()
"Run all tests in an Org test file (trailing `/' matters).
Examples: `ob/' or `ob-python'."
(interactive)
(let ((text (read-string "Org test file (without leading test-): "
nil nil "ob-python")))
(org-test-load)
(let (;; Catch errors in diary sexps better.
(calendar-debug-sexp t))
(ert text)))))
#+end_src
*** LaTex preamble editing using [[info:org#Noweb Reference Syntax][Noweb (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:file-inclusion-and-noweb