diff --git a/lisp/ob-core.el b/lisp/ob-core.el index d422c52d9..9843bb53a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2850,7 +2850,7 @@ CONTEXT may be one of :tangle, :export or :eval." (defvar org-babel-expand-noweb-references--cache nil "Noweb reference cache used during expansion.") (defvar org-babel-expand-noweb-references--cache-buffer nil - "Cons (buffer . modified-tick) for cached noweb references. + "Cons (BUFFER . MODIFIED-TICK) for cached noweb references. See `org-babel-expand-noweb-references--cache'.") (defun org-babel-expand-noweb-references (&optional info parent-buffer) "Expand Noweb references in the body of the current source code block. @@ -3194,33 +3194,25 @@ additionally processed by `shell-quote-argument'." (let ((f (org-babel-local-file-name (expand-file-name name)))) (if no-quote-p f (shell-quote-argument f)))) -(defvar org-babel-temporary-directory) -(unless (or noninteractive (boundp 'org-babel-temporary-directory)) - (defvar org-babel-temporary-directory - (or (and (boundp 'org-babel-temporary-directory) - (file-exists-p org-babel-temporary-directory) - org-babel-temporary-directory) - (make-temp-file "babel-" t)) - "Directory to hold temporary files created to execute code blocks. +(defvar org-babel-temporary-directory + (unless noninteractive + (make-temp-file "babel-" t)) + "Directory to hold temporary files created to execute code blocks. Used by `org-babel-temp-file'. This directory will be removed on -Emacs shutdown.")) +Emacs shutdown.") -(defvar org-babel-temporary-stable-directory) -(unless (or noninteractive (boundp 'org-babel-temporary-stable-directory)) - (defvar org-babel-temporary-stable-directory - (or (and (boundp 'org-babel-temporary-stable-directory) - (file-exists-p org-babel-temporary-stable-directory) - org-babel-temporary-stable-directory) - (let (dir) - (while (or (not dir) (file-exists-p dir)) - (setq dir (expand-file-name - (format "babel-stable-%d" (random 1000)) - (temporary-file-directory)))) - (make-directory dir) - dir)) - "Directory to hold temporary files created to execute code blocks. +(defvar org-babel-temporary-stable-directory + (unless noninteractive + (let (dir) + (while (or (not dir) (file-exists-p dir)) + (setq dir (expand-file-name + (format "babel-stable-%d" (random 1000)) + (temporary-file-directory)))) + (make-directory dir) + dir)) + "Directory to hold temporary files created to execute code blocks. Used by `org-babel-temp-file'. This directory will be removed on -Emacs shutdown.")) +Emacs shutdown.") (defcustom org-babel-remote-temporary-directory "/tmp/" "Directory to hold temporary files on remote hosts." @@ -3258,7 +3250,7 @@ of `org-babel-temporary-directory'." prefix org-babel-remote-temporary-directory)))) (make-temp-file prefix nil suffix)) (let ((temporary-file-directory - (or (and (boundp 'org-babel-temporary-directory) + (or (and org-babel-temporary-directory (file-exists-p org-babel-temporary-directory) org-babel-temporary-directory) temporary-file-directory))) @@ -3277,7 +3269,7 @@ constructed like the following: PREFIXDATAhashSUFFIX." (with-temp-file path) path) (let* ((temporary-file-directory - (or (and (boundp 'org-babel-temporary-stable-directory) + (or (and org-babel-temporary-stable-directory (file-exists-p org-babel-temporary-stable-directory) org-babel-temporary-stable-directory) temporary-file-directory)) @@ -3290,7 +3282,7 @@ constructed like the following: PREFIXDATAhashSUFFIX." (defun org-babel-remove-temporary-directory () "Remove `org-babel-temporary-directory' on Emacs shutdown." - (when (and (boundp 'org-babel-temporary-directory) + (when (and org-babel-temporary-directory (file-exists-p org-babel-temporary-directory)) ;; taken from `delete-directory' in files.el (condition-case nil @@ -3307,13 +3299,12 @@ constructed like the following: PREFIXDATAhashSUFFIX." (delete-directory org-babel-temporary-directory)) (error (message "Failed to remove temporary Org-babel directory %s" - (if (boundp 'org-babel-temporary-directory) - org-babel-temporary-directory - "[directory not defined]")))))) + (or org-babel-temporary-directory + "[directory not defined]")))))) (defun org-babel-remove-temporary-stable-directory () "Remove `org-babel-temporary-stable-directory' and on Emacs shutdown." - (when (and (boundp 'org-babel-temporary-stable-directory) + (when (and org-babel-temporary-stable-directory (file-exists-p org-babel-temporary-stable-directory)) (let ((org-babel-temporary-directory org-babel-temporary-stable-directory)) diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index 604aeb915..c9cd123ea 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -137,7 +137,6 @@ (declare-function org-publish-get-project-from-filename "ox-publish" (filename &optional up)) -(declare-function server-edit "server" (&optional arg)) (defvar org-capture-link-is-already-stored) (defvar org-capture-templates) @@ -671,7 +670,8 @@ CLIENT is ignored." (new-style (not (= ?: (aref (match-string 1 fname) 0))))) (when (plist-get (cdr prolist) :kill-client) (message "Greedy org-protocol handler. Killing client.") - (server-edit)) + ;; If not fboundp, there's no client to kill. + (if (fboundp 'server-edit) (server-edit))) (when (fboundp func) (unless greedy (throw 'fname diff --git a/lisp/org.el b/lisp/org.el index 5eb5b5d6c..bd5a01319 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10325,7 +10325,8 @@ narrowing." ;; When current headline is at the end of buffer and does not ;; end with trailing newline the above can move to the ;; beginning of the headline. - (when (< (point) endpos)) (goto-char endpos))))) + (when (< (point) endpos)) ;; FIXME: Spurious extra paren? + (goto-char endpos))))) (if (bolp) (point) (line-beginning-position 2)))) (defun org-add-log-setup (&optional purpose state prev-state how extra) @@ -14431,9 +14432,11 @@ D may be an absolute day number, or a calendar-type list (month day year)." (cond ((stringp result) (split-string result "; ")) ((and (consp result) (not (consp (cdr result))) - (stringp (cdr result))) (cdr result)) + (stringp (cdr result))) + (cdr result)) ((and (consp result) - (stringp (car result))) result) + (stringp (car result))) + result) (result entry)))) (defun org-diary-to-ical-string (frombuf) diff --git a/testing/examples/babel.el b/testing/examples/babel.el index a7bb0ccf5..cbd522e24 100644 --- a/testing/examples/babel.el +++ b/testing/examples/babel.el @@ -1,3 +1,4 @@ +;; -*- lexical-binding: t; -*- (string-match-p "^#[[:digit:]]+$" "#123") ;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]] diff --git a/testing/lisp/test-ob-C.el b/testing/lisp/test-ob-C.el index 5f1dd1acb..793ca3168 100644 --- a/testing/lisp/test-ob-C.el +++ b/testing/lisp/test-ob-C.el @@ -1,4 +1,4 @@ -;;; test-ob-C.el --- tests for ob-C.el +;;; test-ob-C.el --- tests for ob-C.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov, Thierry Banel ;; Authors: Sergey Litvinov, Thierry Banel diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index 1e60ae903..f6143b994 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -1,4 +1,4 @@ -;;; test-ob-R.el --- tests for ob-R.el +;;; test-ob-R.el --- tests for ob-R.el -*- lexical-binding: t; -*- ;; Copyright (c) 2011-2014, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -20,8 +20,12 @@ ;;; Code: (org-test-for-executable "R") +(require 'ob-core) (unless (featurep 'ess) (signal 'missing-test-dependency "ESS")) +(defvar ess-ask-for-ess-directory) +(defvar ess-history-file) + (unless (featurep 'ob-R) (signal 'missing-test-dependency "Support for R code blocks")) @@ -138,7 +142,7 @@ x 4.0 * 3.5 log(10) log10(10) -(3 + 1) * 5 +\(3 + 1) * 5 3^-1 1/0 #+end_src" diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el index 21151b21f..874d2c026 100644 --- a/testing/lisp/test-ob-awk.el +++ b/testing/lisp/test-ob-awk.el @@ -1,4 +1,4 @@ -;;; test-ob-awk.el --- tests for ob-awk.el +;;; test-ob-awk.el --- tests for ob-awk.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov ;; Authors: Sergey Litvinov diff --git a/testing/lisp/test-ob-clojure.el b/testing/lisp/test-ob-clojure.el index 609fc0ea8..3a21498b4 100644 --- a/testing/lisp/test-ob-clojure.el +++ b/testing/lisp/test-ob-clojure.el @@ -1,4 +1,4 @@ -;;; test-ob-clojure.el +;;; test-ob-clojure.el -*- lexical-binding: t; -*- ;; Copyright (c) 2018-2022 Free Software Foundation, Inc. ;; Authors: stardiviner diff --git a/testing/lisp/test-ob-emacs-lisp.el b/testing/lisp/test-ob-emacs-lisp.el index e7b85d5ba..7592ad7d4 100644 --- a/testing/lisp/test-ob-emacs-lisp.el +++ b/testing/lisp/test-ob-emacs-lisp.el @@ -1,4 +1,4 @@ -;;; test-ob-emacs-lisp.el +;;; test-ob-emacs-lisp.el -*- lexical-binding: t; -*- ;; Copyright (c) 2012-2022 Free Software Foundation, Inc. ;; Authors: Eric Schulte, Martyn Jago @@ -87,22 +87,24 @@ (should (string= "dynamic" (execute " #+begin_src emacs-lisp :lexical no :results verbatim -(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) +\(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) #+end_src"))) (should (string= "lexical" (execute " #+begin_src emacs-lisp :lexical yes :results verbatim -(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) +\(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) #+end_src"))) - (should (string= "dynamic" (let ((x 'dynamic)) (execute " + (defvar ob-emacs--x) + + (should (string= "dynamic" (let ((ob-emacs--x 'dynamic)) (execute " #+begin_src emacs-lisp :lexical no :results verbatim -x +ob-emacs--x #+end_src")))) - (should (string= "lexical" (let ((x 'dynamic)) (execute " -#+begin_src emacs-lisp :lexical '((x . lexical)) :results verbatim -x + (should (string= "lexical" (let ((ob-emacs--x 'dynamic)) (execute " +#+begin_src emacs-lisp :lexical '((ob-emacs--x . lexical)) :results verbatim +ob-emacs--x #+end_src")))) ;; Src block execution uses `eval'. As of 2019-02-26, `eval' does @@ -132,22 +134,23 @@ x (should (eq 'dynamic (execute " #+begin_src emacs-lisp :lexical no :results verbatim -(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) +\(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) #+end_src"))) (should (eq 'lexical (execute " #+begin_src emacs-lisp :lexical yes :results verbatim -(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) +\(let ((x 'dynamic)) (funcall (let ((x 'lexical)) (lambda () x)))) #+end_src"))) - (should (eq 'dynamic (let ((x 'dynamic)) (execute " + (defvar ob-emacs--x) + (should (eq 'dynamic (let ((ob-emacs--x 'dynamic)) (execute " #+begin_src emacs-lisp :lexical no :results verbatim -x +ob-emacs--x #+end_src")))) - (should (eq 'lexical (let ((x 'dynamic)) (execute " -#+begin_src emacs-lisp :lexical '((x . lexical)) :results verbatim -x + (should (eq 'lexical (let ((ob-emacs--x 'dynamic)) (execute " +#+begin_src emacs-lisp :lexical '((ob-emacs--x . lexical)) :results verbatim +ob-emacs--x #+end_src")))) (should (equal nil (execute " diff --git a/testing/lisp/test-ob-eshell.el b/testing/lisp/test-ob-eshell.el index d74742690..4430a21c7 100644 --- a/testing/lisp/test-ob-eshell.el +++ b/testing/lisp/test-ob-eshell.el @@ -1,4 +1,4 @@ -;;; test-ob-eshell.el +;;; test-ob-eshell.el -*- lexical-binding: t; -*- ;; Copyright (c) 2018 stardiviner ;; Authors: stardiviner diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el index 1289745ae..e6fbf14a1 100644 --- a/testing/lisp/test-ob-exp.el +++ b/testing/lisp/test-ob-exp.el @@ -1,4 +1,4 @@ -;;; test-ob-exp.el +;;; test-ob-exp.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2015, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -24,6 +24,10 @@ ;;; Code: +(require 'ob-exp) +(require 'org-src) +(require 'org-test "../testing/org-test") + (defmacro org-test-with-expanded-babel-code (&rest body) "Execute BODY while in a buffer with all Babel code evaluated. Current buffer is a copy of the original buffer." @@ -136,7 +140,7 @@ a table." '(property-drawer plain-list src-block fixed-width src-block plain-list) (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3" (org-narrow-to-subtree) - (mapcar 'org-element-type + (mapcar #'org-element-type (org-element-map (org-test-with-expanded-babel-code (org-element-parse-buffer 'greater-element)) @@ -179,6 +183,7 @@ a table." nil t)))))) (ert-deftest ob-exp/evaluate-all-executables-in-order () + (defvar *evaluation-collector*) (should (equal '(5 4 3 2 1) (let ((org-export-use-babel t) *evaluation-collector*) diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index 79a35d58e..3f821e4da 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -1,4 +1,4 @@ -;;; test-ob-fortran.el --- tests for ob-fortran.el +;;; test-ob-fortran.el --- tests for ob-fortran.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov ;; Authors: Sergey Litvinov diff --git a/testing/lisp/test-ob-header-arg-defaults.el b/testing/lisp/test-ob-header-arg-defaults.el index 1106892d5..beb3ea5b8 100644 --- a/testing/lisp/test-ob-header-arg-defaults.el +++ b/testing/lisp/test-ob-header-arg-defaults.el @@ -1,4 +1,4 @@ -;;; test-ob-header-arg-defaults.el --- tests for default header args from properties +;;; test-ob-header-arg-defaults.el --- tests for default header args from properties -*- lexical-binding: t; -*- ;; Copyright (c) 2013, 2014, 2019 Achim Gratz ;; Authors: Achim Gratz diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el index 56ced2374..b49b952c8 100644 --- a/testing/lisp/test-ob-java.el +++ b/testing/lisp/test-ob-java.el @@ -1,4 +1,4 @@ -;;; test-ob-java.el --- tests for ob-java.el +;;; test-ob-java.el --- tests for ob-java.el -*- lexical-binding: t; -*- ;; Copyright (c) 2020-2022 Free Software Foundation, Inc. ;; Authors: Eric Schulte @@ -22,12 +22,7 @@ ;;; Code: (require 'org-test "../testing/org-test") - (require 'ob-core) -(defvar org-babel-temporary-directory ; from ob-core - (if (boundp 'org-babel-temporary-directory) - org-babel-temporary-directory - (temporary-file-directory))) (org-test-for-executable "java") (org-test-for-executable "javac") diff --git a/testing/lisp/test-ob-julia.el b/testing/lisp/test-ob-julia.el index f6d21726a..1c0f3a5a3 100644 --- a/testing/lisp/test-ob-julia.el +++ b/testing/lisp/test-ob-julia.el @@ -1,4 +1,4 @@ -;;; test-ob-python.el --- tests for ob-python.el +;;; test-ob-python.el --- tests for ob-python.el -*- lexical-binding: t; -*- ;; Copyright (c) 2011-2014, 2019, 2021 Eric Schulte ;; Authors: Pedro Bruel, based on test-ob-python.el by Eric Schulte @@ -21,6 +21,7 @@ ;;; Code: (org-test-for-executable "julia") +(require 'ob-core) (unless (featurep 'ob-julia) (signal 'missing-test-dependency "Support for julia code blocks")) diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el index 1c1d73309..27e1675c9 100644 --- a/testing/lisp/test-ob-lilypond.el +++ b/testing/lisp/test-ob-lilypond.el @@ -1,4 +1,4 @@ -;;; test-ob-lilypond.el --- tests for ob-lilypond.el +;;; test-ob-lilypond.el --- tests for ob-lilypond.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Martyn Jago ;; Authors: Martyn Jago @@ -19,11 +19,9 @@ ;; along with this program. If not, see . ;;; Code: -(unless (featurep 'ob-lilypond) - (signal 'missing-test-dependency "Support for Lilypond code blocks")) +(require 'ob-lilypond) -(save-excursion - (set-buffer (get-buffer-create "test-ob-lilypond.el")) +(with-current-buffer (get-buffer-create "test-ob-lilypond.el") (setq org-babel-lilypond-here (file-name-directory (or load-file-name (buffer-file-name))))) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index c661d5a3e..188fee4c0 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -1,4 +1,4 @@ -;;; test-ob-lob.el --- test for ob-lob.el +;;; test-ob-lob.el --- test for ob-lob.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2015, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -19,6 +19,7 @@ ;; along with this program. If not, see . (eval-and-compile (require 'cl-lib)) +(require 'ob-lob) ;;; Tests @@ -135,6 +136,8 @@ for export #+end_example" (should (progn (org-babel-exp-process-buffer) t)))) +(defvar temporary-value-for-test) + (ert-deftest test-ob-lob/caching-call-line () (let ((temporary-value-for-test 0)) (org-test-with-temp-text " diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el index 7d82dd923..f30e65bb3 100644 --- a/testing/lisp/test-ob-lua.el +++ b/testing/lisp/test-ob-lua.el @@ -1,4 +1,4 @@ -;;; test-ob-lua.el --- tests for ob-lua.el +;;; test-ob-lua.el --- tests for ob-lua.el -*- lexical-binding: t; -*- ;; Copyright (c) 2016, 2019 Thibault Marin ;; Authors: Thibault Marin diff --git a/testing/lisp/test-ob-maxima.el b/testing/lisp/test-ob-maxima.el index 08f7dc04d..e2433d232 100644 --- a/testing/lisp/test-ob-maxima.el +++ b/testing/lisp/test-ob-maxima.el @@ -1,4 +1,4 @@ -;;; test-ob-maxima.el --- tests for ob-maxima.el +;;; test-ob-maxima.el --- tests for ob-maxima.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov ;; Authors: Sergey Litvinov diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el index 6113b40f3..78ce10214 100644 --- a/testing/lisp/test-ob-octave.el +++ b/testing/lisp/test-ob-octave.el @@ -1,4 +1,4 @@ -;;; test-ob-octave.el --- tests for ob-octave.el +;;; test-ob-octave.el --- tests for ob-octave.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov ;; Authors: Sergey Litvinov diff --git a/testing/lisp/test-ob-perl.el b/testing/lisp/test-ob-perl.el index 38521dbba..5826e8cca 100644 --- a/testing/lisp/test-ob-perl.el +++ b/testing/lisp/test-ob-perl.el @@ -1,4 +1,4 @@ -;;; test-ob-perl.el --- tests for ob-perl.el +;;; test-ob-perl.el --- tests for ob-perl.el -*- lexical-binding: t; -*- ;; Copyright (c) 2013, 2014, 2019 Achim Gratz ;; Authors: Achim Gratz diff --git a/testing/lisp/test-ob-plantuml.el b/testing/lisp/test-ob-plantuml.el index bdbd1a74b..b45d38be6 100644 --- a/testing/lisp/test-ob-plantuml.el +++ b/testing/lisp/test-ob-plantuml.el @@ -1,4 +1,4 @@ -;;; test-ob-plantuml.el --- tests for ob-plantuml.el +;;; test-ob-plantuml.el --- tests for ob-plantuml.el -*- lexical-binding: t; -*- ;; Copyright (c) 2016, 2019 Thibault Marin ;; Authors: Thibault Marin @@ -19,8 +19,7 @@ ;; along with this program. If not, see . ;;; Code: -(unless (featurep 'ob-plantuml) - (signal 'missing-test-dependency "Support for PlantUML code blocks")) +(require 'ob-plantuml) (ert-deftest test-ob-plantuml/single-var () "Test file output with input variable." diff --git a/testing/lisp/test-ob-python.el b/testing/lisp/test-ob-python.el index 2032b7e8d..1f5674013 100644 --- a/testing/lisp/test-ob-python.el +++ b/testing/lisp/test-ob-python.el @@ -1,4 +1,4 @@ -;;; test-ob-python.el --- tests for ob-python.el +;;; test-ob-python.el --- tests for ob-python.el -*- lexical-binding: t; -*- ;; Copyright (c) 2011-2014, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -20,6 +20,7 @@ ;;; Code: (org-test-for-executable "python") +(require 'ob-core) (unless (featurep 'ob-python) (signal 'missing-test-dependency "Support for Python code blocks")) diff --git a/testing/lisp/test-ob-ruby.el b/testing/lisp/test-ob-ruby.el index 9f224a765..5e2438c6d 100644 --- a/testing/lisp/test-ob-ruby.el +++ b/testing/lisp/test-ob-ruby.el @@ -1,4 +1,4 @@ -;;; test-ob-ruby.el --- tests for ob-ruby.el +;;; test-ob-ruby.el --- tests for ob-ruby.el -*- lexical-binding: t; -*- ;; Copyright (c) 2013-2015, 2019 Oleh Krehel ;; Authors: Oleh Krehel diff --git a/testing/lisp/test-ob-sed.el b/testing/lisp/test-ob-sed.el index 0c0515ecd..a91aa54cc 100644 --- a/testing/lisp/test-ob-sed.el +++ b/testing/lisp/test-ob-sed.el @@ -1,4 +1,4 @@ -;;; test-ob-sed.el --- tests for ob-sed.el +;;; test-ob-sed.el --- tests for ob-sed.el -*- lexical-binding: t; -*- ;; Copyright (c) 2015, 2019 Bjarte Johansen ;; Authors: Bjarte Johansen diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 6f673740b..a0d5a8d22 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -1,4 +1,4 @@ -;;; test-ob-shell.el +;;; test-ob-shell.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2014, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -24,6 +24,7 @@ ;;; Code: (org-test-for-executable "sh") +(require 'ob-core) (unless (featurep 'ob-shell) (signal 'missing-test-dependency "Support for Shell code blocks")) diff --git a/testing/lisp/test-ob-sql.el b/testing/lisp/test-ob-sql.el index aacdaa7a3..659071121 100644 --- a/testing/lisp/test-ob-sql.el +++ b/testing/lisp/test-ob-sql.el @@ -1,4 +1,4 @@ -;;; test-ob-sql.el --- tests for ob-sql.el +;;; test-ob-sql.el --- tests for ob-sql.el -*- lexical-binding: t; -*- ;; Copyright (C) 2021 Robin Joy diff --git a/testing/lisp/test-ob-sqlite.el b/testing/lisp/test-ob-sqlite.el index c2dc480c2..5c418e304 100644 --- a/testing/lisp/test-ob-sqlite.el +++ b/testing/lisp/test-ob-sqlite.el @@ -1,4 +1,4 @@ -;;; test-ob-sqlite.el --- tests for ob-sqlite.el +;;; test-ob-sqlite.el --- tests for ob-sqlite.el -*- lexical-binding: t; -*- ;; Copyright (C) 2017, 2019 Eduardo Bellani diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el index 3f450c2d7..e83014f2e 100644 --- a/testing/lisp/test-ob-table.el +++ b/testing/lisp/test-ob-table.el @@ -1,4 +1,4 @@ -;;; test-ob-table.el +;;; test-ob-table.el -*- lexical-binding: t; -*- ;; Copyright (c) 2011-2014, 2019 Eric Schulte ;; Authors: Eric Schulte diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 618e118e0..a0003ee40 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -1,4 +1,4 @@ -;;; test-ob-tangle.el --- tests for ob-tangle.el +;;; test-ob-tangle.el --- tests for ob-tangle.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2016, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -26,6 +26,8 @@ ;;; Code: (require 'subr-x) +(require 'ob-tangle) +(require 'org) ;; TODO ;; (ert-deftest ob-tangle/noweb-on-tangle () diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c944ccd39..3e7774a66 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1,4 +1,4 @@ -;;; test-ob.el --- tests for ob.el +;;; test-ob.el --- tests for ob.el -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2015, 2019 Eric Schulte ;; Authors: Eric Schulte, Martyn Jago @@ -20,6 +20,10 @@ ;;; Code: +(require 'ob-core) +(require 'org-src) +(require 'ob-ref) +(require 'org-table) (eval-and-compile (require 'cl-lib)) (ert-deftest test-ob/indented-cached-org-bracket-link () @@ -733,16 +737,17 @@ x (should (looking-at ": 2"))))) (ert-deftest test-ob/eval-header-argument () + (defvar test-ob--foo) (cl-flet ((check-eval (eval runp) (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s - (setq foo :evald) + (setq test-ob--foo :evald) #+end_src" eval) - (let ((foo :not-run)) + (let ((test-ob--foo :not-run)) (if runp (progn (should (org-babel-execute-src-block)) - (should (eq foo :evald))) + (should (eq test-ob--foo :evald))) (progn (should-not (org-babel-execute-src-block)) - (should-not (eq foo :evald)))))))) + (should-not (eq test-ob--foo :evald)))))))) (check-eval "never" nil) (check-eval "no" nil) (check-eval "never-export" t) @@ -1384,6 +1389,7 @@ Line 3\" (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp \(+ 1 2) #+END_SRC\n\n\n" + ;; FIXME: Unknown var `org-babel-next-src-block'? (let ((org-babel-next-src-block "RESULTS")) (org-babel-execute-src-block)) (buffer-string)))) @@ -1537,6 +1543,7 @@ echo \"$data\" (should (re-search-forward org-babel-src-block-regexp nil t)) (goto-char (match-beginning 0)) ;; now that we've located the code block, it may be evaluated + ;; FIXME: Unknown var `org-babel-execute-src-block'? (let ((org-babel-execute-src-block "RESULTS")) (org-babel-execute-src-block)) (buffer-string))))) @@ -1719,6 +1726,7 @@ line 1 (ert-deftest test-ob/noweb-expansions-in-cache () "Ensure that noweb expansions are expanded before caching." + (defvar noweb-expansions-in-cache-var) (let ((noweb-expansions-in-cache-var 0)) (org-test-with-temp-text " #+name: foo diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el index 4c288e983..4b581880b 100644 --- a/testing/lisp/test-oc.el +++ b/testing/lisp/test-oc.el @@ -1591,7 +1591,7 @@ arguments. Replace citation with \"@\" character in the output." '(p1 p1 p1 p3) (org-test-with-temp-text "[cite:@a]" (let ((org-export-registered-backends nil) - (org-cite--procesors nil) + (org-cite--procesors nil) ;FIXME: `org-cite--processors' maybe? (org-cite-export-processors '((b1 . (p1)) (t . (p3))))) @@ -1612,7 +1612,7 @@ arguments. Replace citation with \"@\" character in the output." (eq 'p2 (org-test-with-temp-text "#+cite_export: p2\n[cite:@a]" (let ((org-export-registered-backends nil) - (org-cite--procesors nil) + (org-cite--procesors nil) ;FIXME: `org-cite--processors' maybe? (org-cite-export-processors '((t . (p1))))) (org-cite-register-processor 'p1 :export-citation (lambda (&rest _) (throw :exit 'p1))) diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el index e1cdc8e40..0fbb08460 100644 --- a/testing/lisp/test-ol.el +++ b/testing/lisp/test-ol.el @@ -20,6 +20,8 @@ ;;; Code: (require 'cl-lib) +(require 'ol) +(require 'org-id) ;;; Decode and Encode Links @@ -151,6 +153,7 @@ See https://github.com/yantar92/org/issues/4." (ert-deftest test-org-link/store-link () "Test `org-store-link' specifications." + (defvar org-store-link-props) ;; FIXME: Unknown var! ;; On a headline, link to that headline. Use heading as the ;; description of the link. (should diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 5a2c8933d..12c868186 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -260,7 +260,7 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com" (cl-letf (((symbol-function 'read-char-exclusive) (lambda () ?t)) ((symbol-function 'completing-read) - (lambda (&rest rest) "DONE"))) + (lambda (&rest _rest) "DONE"))) (org-agenda-bulk-action)) (org-agenda-previous-item 99) (should (looking-at ".*DONE a")) @@ -295,7 +295,7 @@ functions." `((?P ;; Custom bulk function ,(lambda (&rest args) - (message "test" args) + (message "test" args) ;FIXME: `args' unused? (setq f-called-cnt (1+ f-called-cnt) f-called-args args)) diff --git a/testing/lisp/test-org-archive.el b/testing/lisp/test-org-archive.el index 9f010d48a..47be89b6d 100644 --- a/testing/lisp/test-org-archive.el +++ b/testing/lisp/test-org-archive.el @@ -19,6 +19,8 @@ ;;; Code: +(require 'org-archive) + (ert-deftest test-org-archive/update-status-cookie () "Test archiving properly updating status cookies." ;; Test org-archive-subtree with two children. diff --git a/testing/lisp/test-org-attach-git.el b/testing/lisp/test-org-attach-git.el index 7fa3a4316..cc2a1dc62 100644 --- a/testing/lisp/test-org-attach-git.el +++ b/testing/lisp/test-org-attach-git.el @@ -1,4 +1,4 @@ -;;; test-org-attach-git.el --- Tests for Org Attach with git-annex +;;; test-org-attach-git.el --- Tests for Org Attach with git-annex -*- lexical-binding: t; -*- ;; ;; Copyright (c) 2016, 2019 Erik Hetzner ;; Authors: Erik Hetzner diff --git a/testing/lisp/test-org-attach.el b/testing/lisp/test-org-attach.el index 6caf93861..4e37c7cf8 100644 --- a/testing/lisp/test-org-attach.el +++ b/testing/lisp/test-org-attach.el @@ -116,7 +116,7 @@ "* foo :foo:" (split-window) (let ((org-buffer (current-buffer)) - (dired-buffer (dired temporary-file-directory))) + (_dired-buffer (dired temporary-file-directory))) (cl-assert (eq 'dired-mode major-mode)) (revert-buffer) (dired-goto-file a-filename) @@ -133,7 +133,8 @@ (mapcar (lambda (x) (string-equal "ATTACH" x)) (plist-get (plist-get - (org-element-at-point) 'headline) :tags)))) + (org-element-at-point) 'headline) + :tags)))) (delete-file a-filename))))) (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/2 () @@ -147,7 +148,7 @@ "* foo" (split-window) (let ((org-buffer (current-buffer)) - (dired-buffer (dired temporary-file-directory))) + (_dired-buffer (dired temporary-file-directory))) (cl-assert (eq 'dired-mode major-mode)) (revert-buffer) (dired-goto-file a-filename) diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el index ea42fa374..47c7ed129 100644 --- a/testing/lisp/test-org-capture.el +++ b/testing/lisp/test-org-capture.el @@ -145,7 +145,7 @@ "** H1 %?" :jump-to-captured t)))) (org-capture nil "t") (cl-letf (((symbol-function 'org-refile-get-location) - (lambda (&rest args) + (lambda (&rest _args) (list (file-name-nondirectory file1) file1 nil nil)))) (org-capture-refile) (list file1 file2 (buffer-file-name))))))))) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index c9768eb6b..f992c8d7a 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -1,4 +1,4 @@ -;;; test-org-clock.el --- Tests for org-clock.el +;;; test-org-clock.el --- Tests for org-clock.el -*- lexical-binding: t; -*- ;; Copyright (C) 2012, 2014, 2015, 2019 Nicolas Goaziou @@ -13,6 +13,9 @@ ;;; Code: +(require 'org-duration) +(require 'org-clock) + (defun org-test-clock-create-timestamp (input &optional inactive with-time) "Create a timestamp out of a date/time prompt string. diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el index e8227b4e6..9daec18e2 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -22,6 +22,9 @@ ;;; Column view (require 'cl-lib) +(require 'org-colview) +(require 'org-duration) +(require 'org-inlinetask) (ert-deftest test-org-colview/get-format () "Test `org-columns-get-format' specifications." @@ -1001,7 +1004,7 @@ (org-test-with-temp-text "* H" (let ((org-columns-default-format "%ITEM %ITEM(Name)") (org-columns-modify-value-for-display-function - (lambda (title value) + (lambda (title _value) (pcase title ("ITEM" "foo") ("Name" "bar") (_ "baz"))))) (org-columns)) (list (get-char-property 1 'org-columns-value-modified) diff --git a/testing/lisp/test-org-datetree.el b/testing/lisp/test-org-datetree.el index 45604f0bb..c66668466 100644 --- a/testing/lisp/test-org-datetree.el +++ b/testing/lisp/test-org-datetree.el @@ -21,6 +21,8 @@ ;;; Code: +(require 'org-datetree) + (ert-deftest test-org-datetree/find-date-create () "Test `org-datetree-find-date-create' specifications." ;; When date is missing, create it. diff --git a/testing/lisp/test-org-duration.el b/testing/lisp/test-org-duration.el index 0a0d2b7d1..760f3207b 100644 --- a/testing/lisp/test-org-duration.el +++ b/testing/lisp/test-org-duration.el @@ -19,6 +19,8 @@ ;;; Code: +(require 'org-duration) + (ert-deftest test-org-duration/to-minutes () "Test `org-duration-to-minutes' specifications." ;; Raise an error for unknown duration format. diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 89eb2a360..187cadf7a 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1,4 +1,4 @@ -;;; test-org-element.el --- Tests for org-element.el +;;; test-org-element.el --- Tests for org-element.el -*- lexical-binding: t; -*- ;; Copyright (C) 2012-2015, 2019 Nicolas Goaziou @@ -21,8 +21,9 @@ (eval-and-compile (require 'cl-lib)) -(unless (featurep 'org-element) - (signal 'missing-test-dependency "org-element")) +(require 'org-element) +(require 'org) +(require 'org-inlinetask) (defun org-test-parse-and-interpret (text) "Parse TEXT as Org syntax and interpret it. @@ -247,7 +248,7 @@ Some other text '(italic entity bold) (org-test-with-temp-text "/some/ *paragraph*" (let* ((tree (org-element-parse-buffer)) - (paragraph (org-element-map tree 'paragraph 'identity nil t)) + (_paragraph (org-element-map tree 'paragraph #'identity nil t)) (bold (org-element-map tree 'bold 'identity nil t))) (org-element-insert-before '(entity (:name "\\alpha")) bold) (org-element-map tree '(bold entity italic) #'org-element-type nil))))) diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index a26346175..0fa800dee 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -1,4 +1,4 @@ -;;; test-org.el --- tests for org.el +;;; test-org.el --- tests for org.el -*- lexical-binding: t; -*- ;; Authors: Ihor Radchenko diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el index 8751dc842..1ab58a989 100644 --- a/testing/lisp/test-org-footnote.el +++ b/testing/lisp/test-org-footnote.el @@ -1,4 +1,4 @@ -;;; test-org-footnote.el --- Tests for org-footnote.el +;;; test-org-footnote.el --- Tests for org-footnote.el -*- lexical-binding: t; -*- ;; Copyright (C) 2012-2015, 2019 Nicolas Goaziou @@ -19,6 +19,8 @@ ;;; Code: +(require 'org-footnote) + (ert-deftest test-org-footnote/new () "Test `org-footnote-new' specifications." ;; `org-footnote-auto-label' is t. diff --git a/testing/lisp/test-org-inlinetask.el b/testing/lisp/test-org-inlinetask.el index db4637679..e31a148a5 100644 --- a/testing/lisp/test-org-inlinetask.el +++ b/testing/lisp/test-org-inlinetask.el @@ -1,4 +1,4 @@ -;;; test-org-inlinetask.el --- Tests for org-inlinetask.el +;;; test-org-inlinetask.el --- Tests for org-inlinetask.el -*- lexical-binding: t; -*- ;; Copyright (c) Marco Wahl ;; Authors: Marco Wahl diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el index 02973acb8..6ee1b1fab 100644 --- a/testing/lisp/test-org-lint.el +++ b/testing/lisp/test-org-lint.el @@ -19,6 +19,9 @@ ;;; Code: +(require 'org-footnote) +(require 'org-lint) + (ert-deftest test-org-lint/add-checker () "Test `org-lint-add-checker'." ;; Name should be a non-nil symbol. @@ -178,7 +181,7 @@ Paragraph 2" (should-not (org-test-with-temp-text "[[(foo)]] #+begin_src emacs-lisp -l \"; ref:%s\" -(+ 1 1) ; ref:foo +\(+ 1 1) ; ref:foo #+end_src" (org-lint '(invalid-coderef-link))))) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index ab6bc5452..1c13c5d97 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -1,4 +1,4 @@ -;;; test-org-list.el --- Tests for org-list.el +;;; test-org-list.el --- Tests for org-list.el -*- lexical-binding: t; -*- ;; Copyright (C) 2012, 2013, 2014, 2018, 2019 Nicolas Goaziou @@ -19,6 +19,9 @@ ;;; Code: +(require 'org-list) +(require 'org) + (ert-deftest test-org-list/list-ending () "Test if lists end at the right place." ;; With two blank lines. @@ -1369,7 +1372,7 @@ b. Item 2" ;; Sort alphabetically. (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp))) (cl-letf (((symbol-function 'string-collate-lessp) - (lambda (s1 s2 &optional locale ignore-case) + (lambda (s1 s2 &optional _locale ignore-case) (funcall original-string-collate-lessp s1 s2 "C" ignore-case)))) (should diff --git a/testing/lisp/test-org-macro.el b/testing/lisp/test-org-macro.el index f1bc4f450..3339945fa 100644 --- a/testing/lisp/test-org-macro.el +++ b/testing/lisp/test-org-macro.el @@ -1,4 +1,4 @@ -;;; test-org-macro.el --- Tests for org-macro.el +;;; test-org-macro.el --- Tests for org-macro.el -*- lexical-binding: t; -*- ;; Copyright (C) 2013, 2014, 2019 Nicolas Goaziou diff --git a/testing/lisp/test-org-pcomplete.el b/testing/lisp/test-org-pcomplete.el index 34969f284..d92520b77 100644 --- a/testing/lisp/test-org-pcomplete.el +++ b/testing/lisp/test-org-pcomplete.el @@ -1,4 +1,4 @@ -;;; test-org-pcomplete.el --- test pcomplete integration +;;; test-org-pcomplete.el --- test pcomplete integration -*- lexical-binding: t; -*- ;; Copyright (C) 2015-2016, 2019 Alexey Lebedeff ;; Authors: Alexey Lebedeff @@ -24,6 +24,8 @@ ;;; Code: +(require 'org) + (ert-deftest test-org-pcomplete/clocktable () "Test completion of clock table parameters." (should diff --git a/testing/lisp/test-org-protocol.el b/testing/lisp/test-org-protocol.el index 95fc7f862..6429432a3 100644 --- a/testing/lisp/test-org-protocol.el +++ b/testing/lisp/test-org-protocol.el @@ -21,9 +21,8 @@ ;;; Code: (require 'cl-lib) - -(unless (featurep 'org-protocol) - (signal 'missing-test-dependency "Support for org-protocol")) +(require 'org-protocol) +(require 'org-capture) (ert-deftest test-org-protocol/org-protocol-parse-parameters () "Test `org-protocol-parse-parameters' specifications." @@ -241,4 +240,5 @@ ;; TODO: Verify greedy protocol handling +(provide 'test-org-protocol) ;;; test-org-protocol.el ends here diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el index 16283b597..2a45ba66e 100644 --- a/testing/lisp/test-org-src.el +++ b/testing/lisp/test-org-src.el @@ -1,4 +1,4 @@ -;;; test-org-src.el --- tests for org-src.el +;;; test-org-src.el --- tests for org-src.el -*- lexical-binding: t; -*- ;; Copyright (C) 2012-2015, 2019 Le Wang diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 310844c94..76fe41630 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1,4 +1,4 @@ -;;; test-org-table.el --- tests for org-table.el +;;; test-org-table.el --- tests for org-table.el -*- lexical-binding: t; -*- ;; Copyright (c) David Maus ;; Authors: David Maus, Michael Brand @@ -28,6 +28,7 @@ ;;; Code: (require 'org-table) ; `org-table-make-reference' +(require 'ox) (ert-deftest test-org-table/simple-formula/no-grouping/no-title-row () "Simple sum without grouping rows, without title row." @@ -1613,7 +1614,7 @@ See also `test-org-table/copy-field'." (should (equal "a\nb" - (let* ((fun-list (list (lambda (backend) (search-forward "a") (insert "hook")))) + (let* ((fun-list (list (lambda (_backend) (search-forward "a") (insert "hook")))) (org-export-before-parsing-hook fun-list) (org-export-before-processing-hook fun-list)) (orgtbl-to-generic (org-table-to-lisp "| a |\n|---|\n| b |") @@ -1622,7 +1623,8 @@ See also `test-org-table/copy-field'." (should (equal "a\nb" - (let ((org-export-filter-table-cell-functions (list (lambda (c b i) "filter")))) + (let ((org-export-filter-table-cell-functions + (list (lambda (_c _b _i) "filter")))) (orgtbl-to-generic (org-table-to-lisp "| a |\n|---|\n| b |") '(:hline nil))))) ;; Macros, even if unknown, are returned as-is. @@ -1891,7 +1893,7 @@ See also `test-org-table/copy-field'." ;; Sort alphabetically. Enforce the C locale for consistent results. (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp))) (cl-letf (((symbol-function 'string-collate-lessp) - (lambda (s1 s2 &optional locale ignore-case) + (lambda (s1 s2 &optional _locale ignore-case) (funcall original-string-collate-lessp s1 s2 "C" ignore-case)))) (should diff --git a/testing/lisp/test-org-timer.el b/testing/lisp/test-org-timer.el index 5d938f22e..bb2db5d56 100644 --- a/testing/lisp/test-org-timer.el +++ b/testing/lisp/test-org-timer.el @@ -1,4 +1,4 @@ -;;; test-org-timer.el --- Tests for org-timer.el +;;; test-org-timer.el --- Tests for org-timer.el -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2015, 2019 Kyle Meyer @@ -22,12 +22,13 @@ ;;; Code: (eval-and-compile (require 'cl-lib)) +(require 'org-timer) (defmacro test-org-timer/with-temp-text (text &rest body) "Like `org-test-with-temp-text', but set timer-specific variables. Also, mute output from `message'." (declare (indent 1)) - `(cl-letf (((symbol-function 'message) (lambda (&rest args) nil))) + `(cl-letf (((symbol-function 'message) (lambda (&rest _args) nil))) (org-test-with-temp-text ,text (let (org-timer-start-time org-timer-pause-time diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 004e89732..7e523be00 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1,4 +1,4 @@ -;;; test-org.el --- tests for org.el +;;; test-org.el --- tests for org.el -*- lexical-binding: t -*- ;; Copyright (c) David Maus ;; Authors: David Maus @@ -23,6 +23,11 @@ ;;; Code: (eval-and-compile (require 'cl-lib)) +(eval-when-compile (require 'org-macs)) ;For `org-with-gensyms'. +(require 'org) +(require 'org-inlinetask) +(require 'org-refile) +(require 'org-agenda) ;;; Helpers @@ -272,6 +277,7 @@ (ert-deftest test-org/org-read-date () "Test `org-read-date' specifications." + (defvar org-time-was-given) ; dynamically scoped parameter ;; Parse ISO date with abbreviated year and month. (should (equal "2012-03-29 16:40" (let ((org-time-was-given t)) @@ -1972,7 +1978,7 @@ "* H <2014-03-05" (org-test-with-temp-text "* H <2014-03-04 Tue>" (cl-letf (((symbol-function 'read-from-minibuffer) - (lambda (&rest args) "+1d"))) + (lambda (&rest _args) "+1d"))) (org-clone-subtree-with-time-shift 1)) (buffer-substring-no-properties (line-beginning-position 2) (line-end-position 2))))) @@ -2664,7 +2670,7 @@ SCHEDULED: <2014-03-04 tue.>" org-current-tag-alist)))) (should (equal '(("A" . ?a) ("B") ("C")) - (let ((org-tag-persistant-alist nil)) + (let ((org-tag-persistant-alist nil)) ;FIXME: persist*e*nt, maybe? (org-test-with-temp-text "#+TAGS: A(a) B C" (org-mode-restart) org-current-tag-alist)))) @@ -3065,14 +3071,14 @@ Foo Bar (org-test-with-temp-text "* H :tag:" (catch :result (cl-letf (((symbol-function 'org-tags-view) - (lambda (&rest args) (throw :result t)))) + (lambda (&rest _args) (throw :result t)))) (org-open-at-point) nil)))) (should-not (org-test-with-temp-text-in-file "* H :tag:" (catch :result (cl-letf (((symbol-function 'org-tags-view) - (lambda (&rest args) (throw :result t)))) + (lambda (&rest _args) (throw :result t)))) ;; When point isn't on a tag it's going to try other things, ;; possibly trying to open attachments which will return an ;; error if there isn't an attachment. Suppress that error. @@ -3738,7 +3744,7 @@ SCHEDULED: <2017-05-06 Sat> (should-not (org-test-with-temp-text "A long line of text\nSome other text" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (org-beginning-of-line) (bolp))) ;; In a wide headline, with `visual-line-mode', prefer going to the @@ -3747,14 +3753,14 @@ SCHEDULED: <2017-05-06 Sat> (should-not (org-test-with-temp-text "* A long headline" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (goto-char (point-max)) (org-beginning-of-line) (bobp))) (should-not (org-test-with-temp-text "* A long headline" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (goto-char (point-max)) (let ((org-special-ctrl-a/e t)) (org-beginning-of-line)) (bobp))) @@ -3854,7 +3860,7 @@ SCHEDULED: <2017-05-06 Sat> (should-not (org-test-with-temp-text "A long line of text\nSome other text" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (goto-char (point-min)) (org-end-of-line) (eolp))) @@ -3869,14 +3875,14 @@ SCHEDULED: <2017-05-06 Sat> (should-not (org-test-with-temp-text "* A long headline" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (goto-char (point-min)) (org-end-of-line) (eolp))) (should-not (org-test-with-temp-text "* A long headline :tag:" (visual-line-mode) - (dotimes (i 1000) (insert "very ")) + (dotimes (_ 1000) (insert "very ")) (goto-char (point-min)) (org-end-of-line) (eolp))) @@ -5629,7 +5635,7 @@ Paragraph" (should (equal "* H\nDEADLINE: <2012-03-29 -705d>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-test-with-temp-text "* H\nDEADLINE: <2012-03-29>" (let ((org-adapt-indentation nil) @@ -5638,7 +5644,7 @@ Paragraph" (buffer-string))))) (should-error (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-test-with-temp-text "* H" (let ((org-adapt-indentation nil) @@ -5741,7 +5747,7 @@ Paragraph" (should (equal "* H\nSCHEDULED: <2012-03-29 -705d>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>" (let ((org-adapt-indentation nil) @@ -5750,7 +5756,7 @@ Paragraph" (buffer-string))))) (should-error (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-test-with-temp-text "* H" (let ((org-adapt-indentation nil) @@ -7307,7 +7313,7 @@ Paragraph" (equal "* H1 :foo:" (org-test-with-temp-text "* H1" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7317,7 +7323,7 @@ Paragraph" (equal "* H1 :foo:\nContents" (org-test-with-temp-text "* H1\nContents" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7326,7 +7332,7 @@ Paragraph" (equal "* H1 :foo:\nContents2" (org-test-with-temp-text "* H1\nContents2" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7338,7 +7344,7 @@ Paragraph" (equal "* H1 :foo:\nContents\n* H2 :foo:" (org-test-with-temp-text "* H1\nContents\n* H2" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-loop-over-headlines-in-active-region t) (org-tags-column 1)) @@ -7351,7 +7357,7 @@ Paragraph" (equal "* H1\nContents\n* H2 :foo:" (org-test-with-temp-text "* H1\nContents\n* H2" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-loop-over-headlines-in-active-region nil) (org-tags-column 1)) @@ -7371,7 +7377,7 @@ Paragraph" (equal ":foo:" (org-test-with-temp-text "* " (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7381,7 +7387,7 @@ Paragraph" (equal "* H1 :foo:" (org-test-with-temp-text "* H1" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7391,7 +7397,7 @@ Paragraph" (equal "* H1 :foo:" (org-test-with-temp-text "** H1" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7401,7 +7407,7 @@ Paragraph" (equal " b :foo:" (org-test-with-temp-text "* a b" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (&rest args) '("foo")))) + (lambda (&rest _args) '("foo")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -7411,7 +7417,7 @@ Paragraph" (equal "b :foo:" (org-test-with-temp-text "* a :foo:\n** b :foo:" (cl-letf (((symbol-function 'completing-read-multiple) - (lambda (prompt coll &optional pred req initial &rest args) + (lambda (_prompt _coll &optional _pred _req initial &rest _) (list initial)))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) @@ -7687,7 +7693,7 @@ Paragraph" (let ((org-todo-keywords '((sequence "TODO" "DONE"))) (org-log-repeat nil)) (cl-letf (((symbol-function 'org-add-log-setup) - (lambda (&rest args) nil))) + (lambda (&rest _args) nil))) (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu. +2y>" (org-todo "DONE") (buffer-string)))))) @@ -7697,7 +7703,7 @@ Paragraph" (let ((org-todo-keywords '((sequence "TODO" "DONE"))) (org-log-repeat t)) (cl-letf (((symbol-function 'org-add-log-setup) - (lambda (&rest args) nil))) + (lambda (&rest _args) nil))) (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu. +2y>" (org-todo "DONE") (buffer-string)))))) @@ -7706,7 +7712,7 @@ Paragraph" ":LAST_REPEAT:" (let ((org-todo-keywords '((sequence "TODO" "DONE")))) (cl-letf (((symbol-function 'org-add-log-setup) - (lambda (&rest args) nil))) + (lambda (&rest _args) nil))) (org-test-with-temp-text "* TODO H\n<2012-03-29 Thu +2y>\nCLOCK: [2012-03-29 Thu 16:40]" (org-todo "DONE") @@ -8016,7 +8022,7 @@ CLOSED: %s "Te<2014-03-04 .*?>xt" (org-test-with-temp-text "Text" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-time-stamp nil) (buffer-string))))) @@ -8026,7 +8032,7 @@ CLOSED: %s "Te<2014-03-04 .*? 00:41>xt" (org-test-with-temp-text "Text" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04 00:41")))) (org-time-stamp '(4)) (buffer-string))))) @@ -8045,7 +8051,7 @@ CLOSED: %s "Te\\[2014-03-04 .*?\\]xt" (org-test-with-temp-text "Text" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-time-stamp nil t) (buffer-string))))) @@ -8055,7 +8061,7 @@ CLOSED: %s "<2014-03-04 .*?>" (org-test-with-temp-text "<2012-03-29 thu.>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-time-stamp nil) (buffer-string))))) @@ -8064,7 +8070,7 @@ CLOSED: %s "<2014-03-04 .*?>--<2014-03-04 .*?>" (org-test-with-temp-text "<2012-03-29 thu.>--<2014-03-04 tue.>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-time-stamp nil) (buffer-string))))) @@ -8074,7 +8080,7 @@ CLOSED: %s "<2014-03-04 .*? \\+2y>" (org-test-with-temp-text "<2012-03-29 thu. +2y>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (org-time-stamp nil) (buffer-string))))) @@ -8084,7 +8090,7 @@ CLOSED: %s "<2012-03-29 .*?>--<2014-03-04 .*?>" (org-test-with-temp-text "<2012-03-29 thu.>" (cl-letf (((symbol-function 'org-read-date) - (lambda (&rest args) + (lambda (&rest _args) (org-time-string-to-time "2014-03-04")))) (let ((last-command 'org-time-stamp) (this-command 'org-time-stamp)) diff --git a/testing/lisp/test-ox-publish.el b/testing/lisp/test-ox-publish.el index b3b0182f1..6419b8f6c 100644 --- a/testing/lisp/test-ox-publish.el +++ b/testing/lisp/test-ox-publish.el @@ -19,6 +19,8 @@ ;;; Code: +(require 'org-test "../testing/org-test") +(require 'ox-publish) ;;; Helper functions @@ -354,20 +356,20 @@ removed from the final plist." (should (apply #'equal - (let* ((ids nil) + (let* (;; (ids nil) (backend (org-export-create-backend :transcoders - '((headline . (lambda (h c i) - (concat (org-export-get-reference h i) " " c))) - (paragraph . (lambda (p c i) c)) - (section . (lambda (s c i) c)) - (link . (lambda (l c i) - (let ((option (org-element-property :search-option l)) - (path (org-element-property :path l))) - (and option - (org-publish-resolve-external-link - option path)))))))) + `((headline . ,(lambda (h c i) + (concat (org-export-get-reference h i) " " c))) + (paragraph . ,(lambda (_p c _i) c)) + (section . ,(lambda (_s c _i) c)) + (link . ,(lambda (l _c _i) + (let ((option (org-element-property :search-option l)) + (path (org-element-property :path l))) + (and option + (org-publish-resolve-external-link + option path)))))))) (publish (lambda (plist filename pub-dir) (org-publish-org-to backend filename ".test" plist pub-dir)))) @@ -387,7 +389,7 @@ removed from the final plist." '("a1" "b1") (let* ((ids nil) (link-transcoder - (lambda (l c i) + (lambda (l _c _i) (let ((option (org-element-property :search-option l)) (path (org-element-property :path l))) (push (org-publish-resolve-external-link option path t) @@ -422,7 +424,7 @@ removed from the final plist." ;; Return nil if no appropriate project is found. (should-not (let* ((base (expand-file-name "examples/pub/" org-test-dir)) - (file (expand-file-name "a.org" base)) + ;; (file (expand-file-name "a.org" base)) (org-publish-project-alist `(("p" :base-directory ,base)))) (org-publish-get-project-from-filename "/other/file.org"))) ;; Return the first project effectively publishing the provided diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 7c71b6e24..4a060e268 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -22,9 +22,8 @@ ;;; Code: (require 'cl-lib) - -(unless (featurep 'ox) - (signal 'missing-test-dependency "org-export")) +(require 'ox) +(require 'org-inlinetask) (defun org-test-default-backend () "Return a default export back-end. @@ -55,6 +54,7 @@ variable, and communication channel under `info'." (org-export--remove-uninterpreted-data tree info) (let ((info (org-combine-plists info (org-export--collect-tree-properties tree info)))) + (ignore info) ;; Don't warn if the var is unused. ,@body)))) @@ -93,6 +93,7 @@ variable, and communication channel under `info'." (format "#+SETUPFILE: \"%s/examples/setupfile.org\"" org-test-dir) (let ((org-export-allow-bind-keywords t)) (org-export-get-environment) + ;; FIXME: `variable'? (eq variable 'value)))) ;; Verify that bound variables are seen during export. (should @@ -2002,11 +2003,11 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] (org-export-create-backend :transcoders (list (cons 'headline - (lambda (headline contents info) + (lambda (headline _contents info) (org-export-data (org-element-property :title headline) info))) - (cons 'plain-text (lambda (text info) "Success")))))) + (cons 'plain-text (lambda (_text _info) "Success")))))) (org-export-string-as "* Test" (org-export-create-backend @@ -2143,7 +2144,7 @@ Para2" (setf (org-export-backend-name backend) 'test) (setf (org-export-backend-transcoders backend) (cons (cons 'export-snippet - (lambda (snippet contents info) + (lambda (snippet _contents _info) (when (eq (org-export-snippet-backend snippet) 'test) (org-element-property :value snippet)))) (org-export-backend-transcoders backend))) @@ -2190,15 +2191,15 @@ Para2" (should (equal "" (org-export-filter-apply-functions - (list (lambda (value &rest _) "") + (list (lambda (_value &rest _) "") (lambda (value &rest _) (concat "2" value))) "0" nil))) ;; Any function returning the empty string short-circuits the ;; process. (should (org-export-filter-apply-functions - (list (lambda (value &rest _) "") - (lambda (value &rest _) (error "This shouldn't happen"))) + (list (lambda (_value &rest _) "") + (lambda (_value &rest _) (error "This shouldn't happen"))) "0" nil))) @@ -2215,7 +2216,7 @@ Para2" (org-export-create-backend :transcoders `(,(cons 'footnote-reference - (lambda (f c i) + (lambda (f _c i) (push (org-export-footnote-first-reference-p f i) result) "")) @@ -2260,7 +2261,7 @@ Para2" (org-export-create-backend :transcoders `(,(cons 'footnote-reference - (lambda (f c i) + (lambda (f _c i) (when (org-element-lineage f '(drawer)) (push (org-export-footnote-first-reference-p f i nil) result)) @@ -2281,7 +2282,7 @@ Para2" (org-export-create-backend :transcoders `(,(cons 'footnote-reference - (lambda (f c i) + (lambda (f _c i) (when (org-element-lineage f '(drawer)) (push (org-export-footnote-first-reference-p f i nil t) result)) @@ -2979,7 +2980,7 @@ Para2" (string-match "success" (progn - (org-link-set-parameters "foo" :export (lambda (p d f i) "success")) + (org-link-set-parameters "foo" :export (lambda (_p _d _f _i) "success")) (org-export-string-as "[[foo:path]]" (org-export-create-backend @@ -2995,7 +2996,7 @@ Para2" "success" (progn (org-link-set-parameters - "foo" :export (lambda (p d f i) (and (eq f 'test) "success"))) + "foo" :export (lambda (_p _d f _i) (and (eq f 'test) "success"))) (org-export-string-as "[[foo:path]]" (org-export-create-backend @@ -3012,7 +3013,7 @@ Para2" "success" (progn (org-link-set-parameters - "foo" :export (lambda (p d f i) (and (eq f 'test) "success"))) + "foo" :export (lambda (_p _d f _i) (and (eq f 'test) "success"))) (org-export-string-as "[[foo:path]]" (org-export-create-backend @@ -5043,7 +5044,8 @@ This test does not cover listings and custom environments." (org-element-type (org-export-get-next-element (org-element-map - (plist-get info :title) 'plain-text 'identity info t) info))))) + (plist-get info :title) 'plain-text 'identity info t) + info))))) ;; Find next element in parsed affiliated keywords. (should (eq 'verbatim @@ -5057,7 +5059,7 @@ This test does not cover listings and custom environments." (equal '(bold code underline) (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_" - (mapcar 'car + (mapcar #'car (org-export-get-next-element (org-element-map tree 'italic 'identity info t) info t))))) ;; When N is a positive integer, return a list containing up to @@ -5066,7 +5068,7 @@ This test does not cover listings and custom environments." (equal '(bold code) (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_" - (mapcar 'car + (mapcar #'car (org-export-get-next-element (org-element-map tree 'italic 'identity info t) info 2)))))) @@ -5109,7 +5111,8 @@ This test does not cover listings and custom environments." (org-element-type (org-export-get-previous-element (org-element-map - (plist-get info :title) 'plain-text 'identity info t) info))))) + (plist-get info :title) 'plain-text 'identity info t) + info))))) ;; Find previous element in parsed affiliated keywords. (should (eq 'verbatim @@ -5122,7 +5125,7 @@ This test does not cover listings and custom environments." (should (equal '(underline italic bold) (org-test-with-parsed-data "_a_ /b/ *c* ~d~" - (mapcar 'car + (mapcar #'car (org-export-get-previous-element (org-element-map tree 'code 'identity info t) info t))))) ;; When N is a positive integer, return a list containing up to @@ -5130,7 +5133,7 @@ This test does not cover listings and custom environments." (should (equal '(italic bold) (org-test-with-parsed-data "_a_ /b/ *c* ~d~" - (mapcar 'car + (mapcar #'car (org-export-get-previous-element (org-element-map tree 'code 'identity info t) info 2)))))) diff --git a/testing/lisp/test-property-inheritance.el b/testing/lisp/test-property-inheritance.el index d3c3b0c64..ede25b490 100644 --- a/testing/lisp/test-property-inheritance.el +++ b/testing/lisp/test-property-inheritance.el @@ -1,4 +1,4 @@ -;;; test-property-inheritance.el --- tests for property-inheritance.el +;;; test-property-inheritance.el --- tests for property-inheritance.el -*- lexical-binding: t; -*- ;; Copyright (c) 2011-2014, 2019 Eric Schulte ;; Authors: Eric Schulte diff --git a/testing/org-batch-test-init.el b/testing/org-batch-test-init.el index 87216cffd..c8a0e3a3e 100644 --- a/testing/org-batch-test-init.el +++ b/testing/org-batch-test-init.el @@ -1,4 +1,4 @@ -;; +;; -*- lexical-binding: t; -*- ;; Remove Org remnants built into Emacs ;; @@ -10,11 +10,13 @@ p)) load-path))) ;; remove property list to defeat cus-load and remove autoloads -(mapatoms (function (lambda (s) - (let ((sn (symbol-name s))) - (when (string-match "^\\(org\\|ob\\|ox\\)\\(-.*\\)?$" sn) - (setplist s nil) - (when (eq 'autoload (car-safe s)) - (unintern s))))))) +(mapatoms (lambda (s) + (let ((sn (symbol-name s))) + (when (string-match "\\`\\(org\\|ob\\|ox\\)\\(-.*\\)?\\'" sn) + (setplist s nil) + ;; FIXME: `s' is a symbol, so (car-safe s) is always nil. + ;;(when (eq 'autoload (car-safe s)) + ;; (unintern s obarray)) + )))) ;; we should now start from a clean slate diff --git a/testing/org-test.el b/testing/org-test.el index 54b21a659..30f96d1f2 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -1,4 +1,4 @@ -;;;; org-test.el --- Tests for Org +;;;; org-test.el --- Tests for Org -*- lexical-binding: t; -*- ;; Copyright (c) 2010-2015 Sebastian Rose, Eric Schulte ;; Authors: @@ -31,6 +31,9 @@ ;;;; Code: +(require 'org) +(require 'org-id) + ;;; Ob constants (defconst org-test-file-ob-anchor @@ -75,7 +78,7 @@ org-test searches this directory up the directory tree.") (defconst org-test-dir (expand-file-name (file-name-directory (or load-file-name buffer-file-name)))) -(defconst org-base-dir +(defconst org-base-dir ;; FIXME: Use `org-test-' prefix. (expand-file-name ".." org-test-dir)) (defconst org-test-example-dir @@ -93,12 +96,13 @@ org-test searches this directory up the directory tree.") (defconst org-test-link-in-heading-file (expand-file-name "link-in-heading.org" org-test-dir)) -(defconst org-id-locations-file +;; FIXME: Merely loading a file shouldn't override a user's settings. +(setq org-id-locations-file (expand-file-name ".test-org-id-locations" org-test-dir)) ;;; Functions for writing tests -(put 'missing-test-dependency +(put 'missing-test-dependency ;FIXME: Use `define-error'. 'error-conditions '(error missing-test-dependency)) @@ -113,18 +117,18 @@ executable." exec-path :initial-value nil) (signal 'missing-test-dependency (list exe)))) -(defun org-test-buffer (&optional file) +(defun org-test-buffer (&optional _file) "TODO: Setup and return a buffer to work with. If file is non-nil insert its contents in there.") -(defun org-test-compare-with-file (&optional file) +(defun org-test-compare-with-file (&optional _file) "TODO: Compare the contents of the test buffer with FILE. If file is not given, search for a file named after the test currently executed.") (defmacro org-test-at-id (id &rest body) "Run body after placing the point in the headline identified by ID." - (declare (indent 1)) + (declare (indent 1) (debug t)) `(let* ((id-location (org-id-find ,id)) (id-file (car id-location)) (visited-p (get-file-buffer id-file)) @@ -142,11 +146,10 @@ currently executed.") (save-restriction ,@body))) (unless (or visited-p (not to-be-removed)) (kill-buffer to-be-removed))))) -(def-edebug-spec org-test-at-id (form body)) (defmacro org-test-in-example-file (file &rest body) "Execute body in the Org example file." - (declare (indent 1)) + (declare (indent 1) (debug t)) `(let* ((my-file (or ,file org-test-file)) (visited-p (get-file-buffer my-file)) to-be-removed @@ -168,26 +171,24 @@ currently executed.") (unless visited-p (kill-buffer to-be-removed)) results)) -(def-edebug-spec org-test-in-example-file (form body)) (defmacro org-test-at-marker (file marker &rest body) "Run body after placing the point at MARKER in FILE. Note the uuidgen command-line command can be useful for generating unique markers for insertion as anchors into org files." - (declare (indent 2)) + (declare (indent 2) (debug t)) `(org-test-in-example-file ,file (goto-char (point-min)) (re-search-forward (regexp-quote ,marker)) ,@body)) -(def-edebug-spec org-test-at-marker (form form body)) (defmacro org-test-with-temp-text (text &rest body) "Run body in a temporary buffer with Org mode as the active mode holding TEXT. If the string \"\" appears in TEXT then remove it and place the point there before running BODY, otherwise place the point at the beginning of the inserted text." - (declare (indent 1)) + (declare (indent 1) (debug t)) `(let ((inside-text (if (stringp ,text) ,text (eval ,text))) (org-mode-hook nil)) (with-temp-buffer @@ -201,20 +202,21 @@ otherwise place the point at the beginning of the inserted text." (goto-char (point-min)))) (font-lock-ensure (point-min) (point-max)) ,@body))) -(def-edebug-spec org-test-with-temp-text (form body)) (defmacro org-test-with-temp-text-in-file (text &rest body) "Run body in a temporary file buffer with Org mode as the active mode. If the string \"\" appears in TEXT then remove it and place the point there before running BODY, otherwise place the point at the beginning of the buffer." - (declare (indent 1)) + (declare (indent 1) (debug t)) `(let ((file (make-temp-file "org-test")) (inside-text (if (stringp ,text) ,text (eval ,text))) buffer) (with-temp-file file (insert inside-text)) (unwind-protect (progn + ;; FIXME: For the rare cases where we do need to mess with windows, + ;; we should let `body' take care of displaying this buffer! (setq buffer (find-file file)) (when (re-search-forward "" nil t) (replace-match "")) @@ -228,15 +230,13 @@ point at the beginning of the buffer." (set-buffer-modified-p nil) (kill-buffer)) (delete-file file))))) -(def-edebug-spec org-test-with-temp-text-in-file (form body)) -(defun org-test-table-target-expect (target &optional expect laps -&rest tblfm) +(defun org-test-table-target-expect (target &optional expect laps &rest tblfm) "For all TBLFM: Apply the formula to TARGET, compare EXPECT with result. Either LAPS and TBLFM are nil and the table will only be aligned or LAPS is the count of recalculations that should be made on each TBLFM. To save ERT run time keep LAPS as low as possible to -get the table stable. Anyhow, if LAPS is 'iterate then iterate, +get the table stable. Anyhow, if LAPS is `iterate' then iterate, but this will run one recalculation longer. When EXPECT is nil it will be set to TARGET. @@ -291,6 +291,8 @@ setting `pp-escape-newlines' to nil manually." (env-def (funcall body env-def)) ((eq system-type 'windows-nt) (funcall body null-device)) (t (require 'tramp) + (defvar tramp-methods) + (defvar tramp-default-host-alist) (let ((tramp-methods (cons '("mock" (tramp-login-program "sh") @@ -321,7 +323,7 @@ Tramp related features. We mostly follow (let ((exp `(progn ,@body))) (if (eval test t) exp - `(when ,test (eval exp t))))) + `(when ,test (eval ',exp t))))) (org--compile-when (featurep 'jump) (defjump org-test-jump @@ -364,7 +366,7 @@ Tramp related features. We mostly follow full-path)) (lambda () ((lambda (res) (if (listp res) (car res) res)) (which-function))))) -(define-key emacs-lisp-mode-map "\M-\C-j" 'org-test-jump) +(define-key emacs-lisp-mode-map "\M-\C-j" #'org-test-jump) ;;; Miscellaneous helper functions @@ -399,8 +401,8 @@ Tramp related features. We mostly follow (lambda (path) (if (file-directory-p path) (rld path) - (condition-case err - (when (string-match "^[A-Za-z].*\\.el$" + (condition-case nil + (when (string-match "\\`[A-Za-z].*\\.el\\'" (file-name-nondirectory path)) (let ((feature-name (intern @@ -415,7 +417,7 @@ Tramp related features. We mostly follow (eval `(ert-deftest ,name () :expected-result :failed (should nil)))))))) (directory-files base 'full - "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$")))) + "\\`\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el\\'")))) (rld (expand-file-name "lisp" org-test-dir)))) (defun org-test-current-defun ()