From 6a0ff3b12dca02ec5e88e4c14a1bc27fb51ca1f6 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Wed, 17 Jan 2024 12:56:00 +0100 Subject: [PATCH] Add "Testing Org" section --- README.org | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/README.org b/README.org index 3e6b882..22d8861 100644 --- a/README.org +++ b/README.org @@ -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