Add "Testing Org" section

This commit is contained in:
Gerard Vermeulen 2024-01-17 12:56:00 +01:00
parent 03911e076b
commit 6a0ff3b12d

View File

@ -3685,6 +3685,97 @@ define the [[https://orgmode.org/][Org mode]] =kbd= macro in listing
(latex (format "@@latex:\\colorbox{PowderBlue}{\\texttt{%s}}@@" keys)))))
#+end_src
*** [[https://orgmode.org/worg/org-tests/index.html][Testing Org]]
:PROPERTIES:
:CUSTOM_ID: sec:testing-org
:END:
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]].
#+caption[Testing Org facilities 1]:
#+caption: Testing Org facilities 1.
#+name: lst:setup-org-mode-test-1
#+begin_src emacs-lisp -n
(with-eval-after-load 'emacs
(defvar org-testing-dir nil)
(defvar org-testing-lisp-files nil)
(defun setup-org-mode-test ()
"Intialize 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")))
(message "`%s'" org-testing-dir)
(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")))))
(message "`%s'" org-testing-lisp-files))
(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))
(file ))
(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.
#+name: lst:setup-org-mode-test-2
#+begin_src emacs-lisp -n
(with-eval-after-load 'emacs
(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-maxima fixed but spacing is fragile. Which Maxima?
;; ob-python hangs sometimes, but very 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-maxima"
"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/"))))
#+end_src
*** [[info:org#Export Settings][File inclusion (info)]] and [[info:org#Noweb Reference Syntax][Noweb (info)]] trickery
:PROPERTIES:
:CUSTOM_ID: sec:file-inclusion-and-noweb