Browse Source

testing: Make all files use `lexical-binding`

Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables.  For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.

Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?

I found some suspicious code, for which I added FIXMEs.

There are also a few changes to the main files.

* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined.  [ Needed to get
the tests to pass. ]

* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it).  Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.

* lisp/org.el (org-log-beginning): Add FIXME.

* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.

* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.

* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded.  Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.

* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler.  Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.

* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.

* testing/lisp/test-org-timer.el: Require `org-timer`.

* testing/lisp/test-org-table.el: Require `ox`.

* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded.  Also require `capture`, and
add missing `provide` statement.

* testing/lisp/test-org-pcomplete.el: Require `org`.

* testing/lisp/test-org-list.el: Require `org-list` and `org`.

* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.

* testing/lisp/test-org-footnote.el: Require `org-footnote`.

* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded.  Also require `org` and
`org-inlinetask`.

* testing/lisp/test-org-duration.el: Require `org-duration`.

* testing/lisp/test-org-datetree.el: Require `org-datetree`.

* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.

* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.

* testing/lisp/test-org-archive.el: Require `org-archive`.

* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.

* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.

* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.

* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.

* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.

* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.

* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.

* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded.  Use `with-current-buffer`.

* testing/lisp/test-ob-julia.el: Require `ob-core`.

* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.

* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.

* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.

* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
Stefan Monnier 2 years ago
parent
commit
1a5e3f931c
60 changed files with 290 additions and 230 deletions
  1. 24 33
      lisp/ob-core.el
  2. 2 2
      lisp/org-protocol.el
  3. 6 3
      lisp/org.el
  4. 1 0
      testing/examples/babel.el
  5. 1 1
      testing/lisp/test-ob-C.el
  6. 6 2
      testing/lisp/test-ob-R.el
  7. 1 1
      testing/lisp/test-ob-awk.el
  8. 1 1
      testing/lisp/test-ob-clojure.el
  9. 18 15
      testing/lisp/test-ob-emacs-lisp.el
  10. 1 1
      testing/lisp/test-ob-eshell.el
  11. 7 2
      testing/lisp/test-ob-exp.el
  12. 1 1
      testing/lisp/test-ob-fortran.el
  13. 1 1
      testing/lisp/test-ob-header-arg-defaults.el
  14. 1 6
      testing/lisp/test-ob-java.el
  15. 2 1
      testing/lisp/test-ob-julia.el
  16. 3 5
      testing/lisp/test-ob-lilypond.el
  17. 4 1
      testing/lisp/test-ob-lob.el
  18. 1 1
      testing/lisp/test-ob-lua.el
  19. 1 1
      testing/lisp/test-ob-maxima.el
  20. 1 1
      testing/lisp/test-ob-octave.el
  21. 1 1
      testing/lisp/test-ob-perl.el
  22. 2 3
      testing/lisp/test-ob-plantuml.el
  23. 2 1
      testing/lisp/test-ob-python.el
  24. 1 1
      testing/lisp/test-ob-ruby.el
  25. 1 1
      testing/lisp/test-ob-sed.el
  26. 2 1
      testing/lisp/test-ob-shell.el
  27. 1 1
      testing/lisp/test-ob-sql.el
  28. 1 1
      testing/lisp/test-ob-sqlite.el
  29. 1 1
      testing/lisp/test-ob-table.el
  30. 3 1
      testing/lisp/test-ob-tangle.el
  31. 13 5
      testing/lisp/test-ob.el
  32. 2 2
      testing/lisp/test-oc.el
  33. 3 0
      testing/lisp/test-ol.el
  34. 2 2
      testing/lisp/test-org-agenda.el
  35. 2 0
      testing/lisp/test-org-archive.el
  36. 1 1
      testing/lisp/test-org-attach-git.el
  37. 4 3
      testing/lisp/test-org-attach.el
  38. 1 1
      testing/lisp/test-org-capture.el
  39. 4 1
      testing/lisp/test-org-clock.el
  40. 4 1
      testing/lisp/test-org-colview.el
  41. 2 0
      testing/lisp/test-org-datetree.el
  42. 2 0
      testing/lisp/test-org-duration.el
  43. 5 4
      testing/lisp/test-org-element.el
  44. 1 1
      testing/lisp/test-org-fold.el
  45. 3 1
      testing/lisp/test-org-footnote.el
  46. 1 1
      testing/lisp/test-org-inlinetask.el
  47. 4 1
      testing/lisp/test-org-lint.el
  48. 5 2
      testing/lisp/test-org-list.el
  49. 1 1
      testing/lisp/test-org-macro.el
  50. 3 1
      testing/lisp/test-org-pcomplete.el
  51. 3 3
      testing/lisp/test-org-protocol.el
  52. 1 1
      testing/lisp/test-org-src.el
  53. 6 4
      testing/lisp/test-org-table.el
  54. 3 2
      testing/lisp/test-org-timer.el
  55. 41 35
      testing/lisp/test-org.el
  56. 15 13
      testing/lisp/test-ox-publish.el
  57. 24 21
      testing/lisp/test-ox.el
  58. 1 1
      testing/lisp/test-property-inheritance.el
  59. 9 7
      testing/org-batch-test-init.el
  60. 26 24
      testing/org-test.el

+ 24 - 33
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
 (defvar org-babel-expand-noweb-references--cache nil
   "Noweb reference cache used during expansion.")
   "Noweb reference cache used during expansion.")
 (defvar org-babel-expand-noweb-references--cache-buffer nil
 (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'.")
 See `org-babel-expand-noweb-references--cache'.")
 (defun org-babel-expand-noweb-references (&optional info parent-buffer)
 (defun org-babel-expand-noweb-references (&optional info parent-buffer)
   "Expand Noweb references in the body of the current source code block.
   "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))))
   (let ((f (org-babel-local-file-name (expand-file-name name))))
     (if no-quote-p f (shell-quote-argument f))))
     (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
 Used by `org-babel-temp-file'.  This directory will be removed on
-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.
+Emacs shutdown.")
+
+(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
 Used by `org-babel-temp-file'.  This directory will be removed on
-Emacs shutdown."))
+Emacs shutdown.")
 
 
 (defcustom org-babel-remote-temporary-directory "/tmp/"
 (defcustom org-babel-remote-temporary-directory "/tmp/"
   "Directory to hold temporary files on remote hosts."
   "Directory to hold temporary files on remote hosts."
@@ -3258,7 +3250,7 @@ of `org-babel-temporary-directory'."
 		      prefix org-babel-remote-temporary-directory))))
 		      prefix org-babel-remote-temporary-directory))))
         (make-temp-file prefix nil suffix))
         (make-temp-file prefix nil suffix))
     (let ((temporary-file-directory
     (let ((temporary-file-directory
-	   (or (and (boundp 'org-babel-temporary-directory)
+	   (or (and org-babel-temporary-directory
 		    (file-exists-p org-babel-temporary-directory)
 		    (file-exists-p org-babel-temporary-directory)
 		    org-babel-temporary-directory)
 		    org-babel-temporary-directory)
 	       temporary-file-directory)))
 	       temporary-file-directory)))
@@ -3277,7 +3269,7 @@ constructed like the following: PREFIXDATAhashSUFFIX."
         (with-temp-file path)
         (with-temp-file path)
         path)
         path)
     (let* ((temporary-file-directory
     (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)
 		     (file-exists-p org-babel-temporary-stable-directory)
 		     org-babel-temporary-stable-directory)
 		     org-babel-temporary-stable-directory)
 	        temporary-file-directory))
 	        temporary-file-directory))
@@ -3290,7 +3282,7 @@ constructed like the following: PREFIXDATAhashSUFFIX."
 
 
 (defun org-babel-remove-temporary-directory ()
 (defun org-babel-remove-temporary-directory ()
   "Remove `org-babel-temporary-directory' on Emacs shutdown."
   "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))
 	     (file-exists-p org-babel-temporary-directory))
     ;; taken from `delete-directory' in files.el
     ;; taken from `delete-directory' in files.el
     (condition-case nil
     (condition-case nil
@@ -3307,13 +3299,12 @@ constructed like the following: PREFIXDATAhashSUFFIX."
 	  (delete-directory org-babel-temporary-directory))
 	  (delete-directory org-babel-temporary-directory))
       (error
       (error
        (message "Failed to remove temporary Org-babel directory %s"
        (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 ()
 (defun org-babel-remove-temporary-stable-directory ()
   "Remove `org-babel-temporary-stable-directory' and on Emacs shutdown."
   "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))
 	     (file-exists-p org-babel-temporary-stable-directory))
     (let ((org-babel-temporary-directory
     (let ((org-babel-temporary-directory
            org-babel-temporary-stable-directory))
            org-babel-temporary-stable-directory))

+ 2 - 2
lisp/org-protocol.el

@@ -137,7 +137,6 @@
 
 
 (declare-function org-publish-get-project-from-filename "ox-publish"
 (declare-function org-publish-get-project-from-filename "ox-publish"
 		  (filename &optional up))
 		  (filename &optional up))
-(declare-function server-edit "server" (&optional arg))
 
 
 (defvar org-capture-link-is-already-stored)
 (defvar org-capture-link-is-already-stored)
 (defvar org-capture-templates)
 (defvar org-capture-templates)
@@ -671,7 +670,8 @@ CLIENT is ignored."
 		       (new-style (not (= ?: (aref (match-string 1 fname) 0)))))
 		       (new-style (not (= ?: (aref (match-string 1 fname) 0)))))
                   (when (plist-get (cdr prolist) :kill-client)
                   (when (plist-get (cdr prolist) :kill-client)
 		    (message "Greedy org-protocol handler.  Killing 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)
                   (when (fboundp func)
                     (unless greedy
                     (unless greedy
                       (throw 'fname
                       (throw 'fname

+ 6 - 3
lisp/org.el

@@ -10325,7 +10325,8 @@ narrowing."
          ;; When current headline is at the end of buffer and does not
          ;; When current headline is at the end of buffer and does not
          ;; end with trailing newline the above can move to the
          ;; end with trailing newline the above can move to the
          ;; beginning of the headline.
          ;; 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))))
    (if (bolp) (point) (line-beginning-position 2))))
 
 
 (defun org-add-log-setup (&optional purpose state prev-state how extra)
 (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 "; "))
     (cond ((stringp result) (split-string result "; "))
 	  ((and (consp result)
 	  ((and (consp result)
 		(not (consp (cdr result)))
 		(not (consp (cdr result)))
-		(stringp (cdr result))) (cdr result))
+		(stringp (cdr result)))
+	   (cdr result))
 	  ((and (consp result)
 	  ((and (consp result)
-		(stringp (car result))) result)
+		(stringp (car result)))
+	   result)
 	  (result entry))))
 	  (result entry))))
 
 
 (defun org-diary-to-ical-string (frombuf)
 (defun org-diary-to-ical-string (frombuf)

+ 1 - 0
testing/examples/babel.el

@@ -1,3 +1,4 @@
+;; -*- lexical-binding: t; -*-
 (string-match-p "^#[[:digit:]]+$" "#123")
 (string-match-p "^#[[:digit:]]+$" "#123")
 
 
 ;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]
 ;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]

+ 1 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov, Thierry Banel
 ;; Authors: Sergey Litvinov, Thierry Banel
 ;; Authors: Sergey Litvinov, Thierry Banel

+ 6 - 2
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
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -20,8 +20,12 @@
 
 
 ;;; Code:
 ;;; Code:
 (org-test-for-executable "R")
 (org-test-for-executable "R")
+(require 'ob-core)
 (unless (featurep 'ess)
 (unless (featurep 'ess)
   (signal 'missing-test-dependency "ESS"))
   (signal 'missing-test-dependency "ESS"))
+(defvar ess-ask-for-ess-directory)
+(defvar ess-history-file)
+
 (unless (featurep 'ob-R)
 (unless (featurep 'ob-R)
   (signal 'missing-test-dependency "Support for R code blocks"))
   (signal 'missing-test-dependency "Support for R code blocks"))
 
 
@@ -138,7 +142,7 @@ x
 4.0 * 3.5
 4.0 * 3.5
 log(10)
 log(10)
 log10(10)
 log10(10)
-(3 + 1) * 5
+\(3 + 1) * 5
 3^-1
 3^-1
 1/0
 1/0
 #+end_src"
 #+end_src"

+ 1 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
 ;; Authors: Sergey Litvinov

+ 1 - 1
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.
 ;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
 ;; Authors: stardiviner
 ;; Authors: stardiviner

+ 18 - 15
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.
 ;; Copyright (c) 2012-2022 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte, Martyn Jago
 ;; Authors: Eric Schulte, Martyn Jago
@@ -87,22 +87,24 @@
 
 
     (should (string= "dynamic" (execute "
     (should (string= "dynamic" (execute "
 #+begin_src emacs-lisp :lexical no :results verbatim
 #+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")))
 #+end_src")))
 
 
     (should (string= "lexical" (execute "
     (should (string= "lexical" (execute "
 #+begin_src emacs-lisp :lexical yes :results verbatim
 #+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")))
 #+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
 #+begin_src emacs-lisp :lexical no :results verbatim
-x
+ob-emacs--x
 #+end_src"))))
 #+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"))))
 #+end_src"))))
 
 
     ;; Src block execution uses `eval'. As of 2019-02-26, `eval' does
     ;; Src block execution uses `eval'. As of 2019-02-26, `eval' does
@@ -132,22 +134,23 @@ x
 
 
     (should (eq 'dynamic (execute "
     (should (eq 'dynamic (execute "
 #+begin_src emacs-lisp :lexical no :results verbatim
 #+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")))
 #+end_src")))
 
 
     (should (eq 'lexical (execute "
     (should (eq 'lexical (execute "
 #+begin_src emacs-lisp :lexical yes :results verbatim
 #+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")))
 #+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
 #+begin_src emacs-lisp :lexical no :results verbatim
-x
+ob-emacs--x
 #+end_src"))))
 #+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"))))
 #+end_src"))))
 
 
     (should (equal nil (execute "
     (should (equal nil (execute "

+ 1 - 1
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
 ;; Copyright (c) 2018 stardiviner
 ;; Authors: stardiviner
 ;; Authors: stardiviner

+ 7 - 2
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
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -24,6 +24,10 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'ob-exp)
+(require 'org-src)
+(require 'org-test "../testing/org-test")
+
 (defmacro org-test-with-expanded-babel-code (&rest body)
 (defmacro org-test-with-expanded-babel-code (&rest body)
   "Execute BODY while in a buffer with all Babel code evaluated.
   "Execute BODY while in a buffer with all Babel code evaluated.
 Current buffer is a copy of the original buffer."
 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)
     '(property-drawer plain-list src-block fixed-width src-block plain-list)
     (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
     (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
       (org-narrow-to-subtree)
       (org-narrow-to-subtree)
-      (mapcar 'org-element-type
+      (mapcar #'org-element-type
 	      (org-element-map
 	      (org-element-map
 		  (org-test-with-expanded-babel-code
 		  (org-test-with-expanded-babel-code
 		   (org-element-parse-buffer 'greater-element))
 		   (org-element-parse-buffer 'greater-element))
@@ -179,6 +183,7 @@ a table."
 	 nil t))))))
 	 nil t))))))
 
 
 (ert-deftest ob-exp/evaluate-all-executables-in-order ()
 (ert-deftest ob-exp/evaluate-all-executables-in-order ()
+  (defvar *evaluation-collector*)
   (should
   (should
    (equal '(5 4 3 2 1)
    (equal '(5 4 3 2 1)
 	  (let ((org-export-use-babel t) *evaluation-collector*)
 	  (let ((org-export-use-babel t) *evaluation-collector*)

+ 1 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
 ;; Authors: Sergey Litvinov

+ 1 - 1
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
 ;; Copyright (c) 2013, 2014, 2019 Achim Gratz
 ;; Authors: Achim Gratz
 ;; Authors: Achim Gratz

+ 1 - 6
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.
 ;; Copyright (c) 2020-2022 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -22,12 +22,7 @@
 
 
 ;;; Code:
 ;;; Code:
 (require 'org-test "../testing/org-test")
 (require 'org-test "../testing/org-test")
-
 (require 'ob-core)
 (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 "java")
 (org-test-for-executable "javac")
 (org-test-for-executable "javac")

+ 2 - 1
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
 ;; Copyright (c) 2011-2014, 2019, 2021 Eric Schulte
 ;; Authors: Pedro Bruel, based on test-ob-python.el by Eric Schulte
 ;; Authors: Pedro Bruel, based on test-ob-python.el by Eric Schulte
@@ -21,6 +21,7 @@
 
 
 ;;; Code:
 ;;; Code:
 (org-test-for-executable "julia")
 (org-test-for-executable "julia")
+(require 'ob-core)
 (unless (featurep 'ob-julia)
 (unless (featurep 'ob-julia)
   (signal 'missing-test-dependency "Support for julia code blocks"))
   (signal 'missing-test-dependency "Support for julia code blocks"))
 
 

+ 3 - 5
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
 ;; Copyright (c) 2010-2014, 2019 Martyn Jago
 ;; Authors: Martyn Jago
 ;; Authors: Martyn Jago
@@ -19,11 +19,9 @@
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 
 ;;; Code:
 ;;; 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
   (setq org-babel-lilypond-here
         (file-name-directory
         (file-name-directory
          (or load-file-name (buffer-file-name)))))
          (or load-file-name (buffer-file-name)))))

+ 4 - 1
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
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -19,6 +19,7 @@
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 
 (eval-and-compile (require 'cl-lib))
 (eval-and-compile (require 'cl-lib))
+(require 'ob-lob)
 
 
 
 
 ;;; Tests
 ;;; Tests
@@ -135,6 +136,8 @@ for export
 #+end_example"
 #+end_example"
     (should (progn (org-babel-exp-process-buffer) t))))
     (should (progn (org-babel-exp-process-buffer) t))))
 
 
+(defvar temporary-value-for-test)
+
 (ert-deftest test-ob-lob/caching-call-line ()
 (ert-deftest test-ob-lob/caching-call-line ()
   (let ((temporary-value-for-test 0))
   (let ((temporary-value-for-test 0))
     (org-test-with-temp-text "
     (org-test-with-temp-text "

+ 1 - 1
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
 ;; Copyright (c) 2016, 2019 Thibault Marin
 ;; Authors: Thibault Marin
 ;; Authors: Thibault Marin

+ 1 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
 ;; Authors: Sergey Litvinov

+ 1 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
 ;; Authors: Sergey Litvinov

+ 1 - 1
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
 ;; Copyright (c) 2013, 2014, 2019 Achim Gratz
 ;; Authors: Achim Gratz
 ;; Authors: Achim Gratz

+ 2 - 3
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
 ;; Copyright (c) 2016, 2019 Thibault Marin
 ;; Authors: Thibault Marin
 ;; Authors: Thibault Marin
@@ -19,8 +19,7 @@
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 
 ;;; Code:
 ;;; Code:
-(unless (featurep 'ob-plantuml)
-  (signal 'missing-test-dependency "Support for PlantUML code blocks"))
+(require 'ob-plantuml)
 
 
 (ert-deftest test-ob-plantuml/single-var ()
 (ert-deftest test-ob-plantuml/single-var ()
   "Test file output with input variable."
   "Test file output with input variable."

+ 2 - 1
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
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -20,6 +20,7 @@
 
 
 ;;; Code:
 ;;; Code:
 (org-test-for-executable "python")
 (org-test-for-executable "python")
+(require 'ob-core)
 (unless (featurep 'ob-python)
 (unless (featurep 'ob-python)
   (signal 'missing-test-dependency "Support for Python code blocks"))
   (signal 'missing-test-dependency "Support for Python code blocks"))
 
 

+ 1 - 1
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
 ;; Copyright (c) 2013-2015, 2019 Oleh Krehel
 ;; Authors: Oleh Krehel
 ;; Authors: Oleh Krehel

+ 1 - 1
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
 ;; Copyright (c) 2015, 2019 Bjarte Johansen
 ;; Authors: Bjarte Johansen
 ;; Authors: Bjarte Johansen

+ 2 - 1
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
 ;; Copyright (c) 2010-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -24,6 +24,7 @@
 
 
 ;;; Code:
 ;;; Code:
 (org-test-for-executable "sh")
 (org-test-for-executable "sh")
+(require 'ob-core)
 (unless (featurep 'ob-shell)
 (unless (featurep 'ob-shell)
   (signal 'missing-test-dependency "Support for Shell code blocks"))
   (signal 'missing-test-dependency "Support for Shell code blocks"))
 
 

+ 1 - 1
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
 ;; Copyright (C) 2021 Robin Joy
 
 

+ 1 - 1
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
 ;; Copyright (C) 2017, 2019  Eduardo Bellani
 
 

+ 1 - 1
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
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte

+ 3 - 1
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
 ;; Copyright (c) 2010-2016, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte
@@ -26,6 +26,8 @@
 ;;; Code:
 ;;; Code:
 
 
 (require 'subr-x)
 (require 'subr-x)
+(require 'ob-tangle)
+(require 'org)
 
 
 ;; TODO
 ;; TODO
 ;; (ert-deftest ob-tangle/noweb-on-tangle ()
 ;; (ert-deftest ob-tangle/noweb-on-tangle ()

+ 13 - 5
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
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte, Martyn Jago
 ;; Authors: Eric Schulte, Martyn Jago
@@ -20,6 +20,10 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'ob-core)
+(require 'org-src)
+(require 'ob-ref)
+(require 'org-table)
 (eval-and-compile (require 'cl-lib))
 (eval-and-compile (require 'cl-lib))
 
 
 (ert-deftest test-ob/indented-cached-org-bracket-link ()
 (ert-deftest test-ob/indented-cached-org-bracket-link ()
@@ -733,16 +737,17 @@ x
       (should (looking-at ": 2")))))
       (should (looking-at ": 2")))))
 
 
 (ert-deftest test-ob/eval-header-argument ()
 (ert-deftest test-ob/eval-header-argument ()
+  (defvar test-ob--foo)
   (cl-flet ((check-eval (eval runp)
   (cl-flet ((check-eval (eval runp)
 			(org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
 			(org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
-  (setq foo :evald)
+  (setq test-ob--foo :evald)
 #+end_src" eval)
 #+end_src" eval)
-			  (let ((foo :not-run))
+			  (let ((test-ob--foo :not-run))
 			    (if runp
 			    (if runp
 				(progn (should (org-babel-execute-src-block))
 				(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))
 			      (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 "never" nil)
     (check-eval "no" nil)
     (check-eval "no" nil)
     (check-eval "never-export" t)
     (check-eval "never-export" t)
@@ -1384,6 +1389,7 @@ Line 3\"
 	  (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
 	  (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
 \(+ 1 2)
 \(+ 1 2)
 #+END_SRC\n\n\n"
 #+END_SRC\n\n\n"
+	    ;; FIXME: Unknown var `org-babel-next-src-block'?
 	    (let ((org-babel-next-src-block "RESULTS"))
 	    (let ((org-babel-next-src-block "RESULTS"))
 	      (org-babel-execute-src-block))
 	      (org-babel-execute-src-block))
 	    (buffer-string))))
 	    (buffer-string))))
@@ -1537,6 +1543,7 @@ echo \"$data\"
 	    (should (re-search-forward org-babel-src-block-regexp nil t))
 	    (should (re-search-forward org-babel-src-block-regexp nil t))
 	    (goto-char (match-beginning 0))
 	    (goto-char (match-beginning 0))
 	    ;; now that we've located the code block, it may be evaluated
 	    ;; 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"))
 	    (let ((org-babel-execute-src-block "RESULTS"))
 	      (org-babel-execute-src-block))
 	      (org-babel-execute-src-block))
 	    (buffer-string)))))
 	    (buffer-string)))))
@@ -1719,6 +1726,7 @@ line 1
 
 
 (ert-deftest test-ob/noweb-expansions-in-cache ()
 (ert-deftest test-ob/noweb-expansions-in-cache ()
   "Ensure that noweb expansions are expanded before caching."
   "Ensure that noweb expansions are expanded before caching."
+  (defvar noweb-expansions-in-cache-var)
   (let ((noweb-expansions-in-cache-var 0))
   (let ((noweb-expansions-in-cache-var 0))
     (org-test-with-temp-text "
     (org-test-with-temp-text "
 #+name: foo
 #+name: foo

+ 2 - 2
testing/lisp/test-oc.el

@@ -1591,7 +1591,7 @@ arguments.  Replace citation with \"@\" character in the output."
     '(p1 p1 p1 p3)
     '(p1 p1 p1 p3)
     (org-test-with-temp-text "[cite:@a]"
     (org-test-with-temp-text "[cite:@a]"
       (let ((org-export-registered-backends nil)
       (let ((org-export-registered-backends nil)
-            (org-cite--procesors nil)
+            (org-cite--procesors nil)   ;FIXME: `org-cite--processors' maybe?
             (org-cite-export-processors
             (org-cite-export-processors
              '((b1 . (p1))
              '((b1 . (p1))
                (t  . (p3)))))
                (t  . (p3)))))
@@ -1612,7 +1612,7 @@ arguments.  Replace citation with \"@\" character in the output."
    (eq 'p2
    (eq 'p2
        (org-test-with-temp-text "#+cite_export: p2\n[cite:@a]"
        (org-test-with-temp-text "#+cite_export: p2\n[cite:@a]"
          (let ((org-export-registered-backends nil)
          (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-export-processors '((t  . (p1)))))
            (org-cite-register-processor 'p1
            (org-cite-register-processor 'p1
              :export-citation (lambda (&rest _) (throw :exit 'p1)))
              :export-citation (lambda (&rest _) (throw :exit 'p1)))

+ 3 - 0
testing/lisp/test-ol.el

@@ -20,6 +20,8 @@
 ;;; Code:
 ;;; Code:
 
 
 (require 'cl-lib)
 (require 'cl-lib)
+(require 'ol)
+(require 'org-id)
 
 
 
 
 ;;; Decode and Encode Links
 ;;; Decode and Encode Links
@@ -151,6 +153,7 @@ See https://github.com/yantar92/org/issues/4."
 
 
 (ert-deftest test-org-link/store-link ()
 (ert-deftest test-org-link/store-link ()
   "Test `org-store-link' specifications."
   "Test `org-store-link' specifications."
+  (defvar org-store-link-props) ;; FIXME: Unknown var!
   ;; On a headline, link to that headline.  Use heading as the
   ;; On a headline, link to that headline.  Use heading as the
   ;; description of the link.
   ;; description of the link.
   (should
   (should

+ 2 - 2
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)
     (cl-letf (((symbol-function 'read-char-exclusive)
                (lambda () ?t))
                (lambda () ?t))
               ((symbol-function 'completing-read)
               ((symbol-function 'completing-read)
-               (lambda (&rest rest) "DONE")))
+               (lambda (&rest _rest) "DONE")))
       (org-agenda-bulk-action))
       (org-agenda-bulk-action))
     (org-agenda-previous-item 99)
     (org-agenda-previous-item 99)
     (should (looking-at ".*DONE a"))
     (should (looking-at ".*DONE a"))
@@ -295,7 +295,7 @@ functions."
             `((?P
             `((?P
                ;; Custom bulk function
                ;; Custom bulk function
                ,(lambda (&rest args)
                ,(lambda (&rest args)
-                  (message "test" args)
+                  (message "test" args) ;FIXME: `args' unused?
                   (setq f-called-cnt (1+ f-called-cnt)
                   (setq f-called-cnt (1+ f-called-cnt)
 
 
                         f-called-args args))
                         f-called-args args))

+ 2 - 0
testing/lisp/test-org-archive.el

@@ -19,6 +19,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-archive)
+
 (ert-deftest test-org-archive/update-status-cookie ()
 (ert-deftest test-org-archive/update-status-cookie ()
   "Test archiving properly updating status cookies."
   "Test archiving properly updating status cookies."
   ;; Test org-archive-subtree with two children.
   ;; Test org-archive-subtree with two children.

+ 1 - 1
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
 ;; Copyright (c) 2016, 2019 Erik Hetzner
 ;; Authors: Erik Hetzner
 ;; Authors: Erik Hetzner

+ 4 - 3
testing/lisp/test-org-attach.el

@@ -116,7 +116,7 @@
 	     "* foo   :foo:"
 	     "* foo   :foo:"
 	   (split-window)
 	   (split-window)
 	   (let ((org-buffer (current-buffer))
 	   (let ((org-buffer (current-buffer))
-		 (dired-buffer (dired temporary-file-directory)))
+		 (_dired-buffer (dired temporary-file-directory)))
 	     (cl-assert (eq 'dired-mode major-mode))
 	     (cl-assert (eq 'dired-mode major-mode))
 	     (revert-buffer)
 	     (revert-buffer)
 	     (dired-goto-file a-filename)
 	     (dired-goto-file a-filename)
@@ -133,7 +133,8 @@
 		      (mapcar (lambda (x) (string-equal "ATTACH" x))
 		      (mapcar (lambda (x) (string-equal "ATTACH" x))
 			      (plist-get
 			      (plist-get
 			       (plist-get
 			       (plist-get
-				(org-element-at-point) 'headline) :tags))))
+				(org-element-at-point) 'headline)
+			       :tags))))
        (delete-file a-filename)))))
        (delete-file a-filename)))))
 
 
 (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/2 ()
 (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/2 ()
@@ -147,7 +148,7 @@
 	  "* foo"
 	  "* foo"
 	  (split-window)
 	  (split-window)
 	  (let ((org-buffer (current-buffer))
 	  (let ((org-buffer (current-buffer))
-		(dired-buffer (dired temporary-file-directory)))
+		(_dired-buffer (dired temporary-file-directory)))
 	    (cl-assert (eq 'dired-mode major-mode))
 	    (cl-assert (eq 'dired-mode major-mode))
 	    (revert-buffer)
 	    (revert-buffer)
 	    (dired-goto-file a-filename)
 	    (dired-goto-file a-filename)

+ 1 - 1
testing/lisp/test-org-capture.el

@@ -145,7 +145,7 @@
 		    "** H1 %?" :jump-to-captured t))))
 		    "** H1 %?" :jump-to-captured t))))
 	   (org-capture nil "t")
 	   (org-capture nil "t")
 	   (cl-letf (((symbol-function 'org-refile-get-location)
 	   (cl-letf (((symbol-function 'org-refile-get-location)
-		      (lambda (&rest args)
+		      (lambda (&rest _args)
 			(list (file-name-nondirectory file1) file1 nil nil))))
 			(list (file-name-nondirectory file1) file1 nil nil))))
 	     (org-capture-refile)
 	     (org-capture-refile)
 	     (list file1 file2 (buffer-file-name)))))))))
 	     (list file1 file2 (buffer-file-name)))))))))

+ 4 - 1
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
 ;; Copyright (C) 2012, 2014, 2015, 2019  Nicolas Goaziou
 
 
@@ -13,6 +13,9 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-duration)
+(require 'org-clock)
+
 (defun org-test-clock-create-timestamp (input &optional inactive with-time)
 (defun org-test-clock-create-timestamp (input &optional inactive with-time)
   "Create a timestamp out of a date/time prompt string.
   "Create a timestamp out of a date/time prompt string.
 
 

+ 4 - 1
testing/lisp/test-org-colview.el

@@ -22,6 +22,9 @@
 ;;; Column view
 ;;; Column view
 
 
 (require 'cl-lib)
 (require 'cl-lib)
+(require 'org-colview)
+(require 'org-duration)
+(require 'org-inlinetask)
 
 
 (ert-deftest test-org-colview/get-format ()
 (ert-deftest test-org-colview/get-format ()
   "Test `org-columns-get-format' specifications."
   "Test `org-columns-get-format' specifications."
@@ -1001,7 +1004,7 @@
 	  (org-test-with-temp-text "* H"
 	  (org-test-with-temp-text "* H"
 	    (let ((org-columns-default-format "%ITEM %ITEM(Name)")
 	    (let ((org-columns-default-format "%ITEM %ITEM(Name)")
 		  (org-columns-modify-value-for-display-function
 		  (org-columns-modify-value-for-display-function
-		   (lambda (title value)
+		   (lambda (title _value)
 		     (pcase title ("ITEM" "foo") ("Name" "bar") (_ "baz")))))
 		     (pcase title ("ITEM" "foo") ("Name" "bar") (_ "baz")))))
 	      (org-columns))
 	      (org-columns))
 	    (list (get-char-property 1 'org-columns-value-modified)
 	    (list (get-char-property 1 'org-columns-value-modified)

+ 2 - 0
testing/lisp/test-org-datetree.el

@@ -21,6 +21,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-datetree)
+
 (ert-deftest test-org-datetree/find-date-create ()
 (ert-deftest test-org-datetree/find-date-create ()
   "Test `org-datetree-find-date-create' specifications."
   "Test `org-datetree-find-date-create' specifications."
   ;; When date is missing, create it.
   ;; When date is missing, create it.

+ 2 - 0
testing/lisp/test-org-duration.el

@@ -19,6 +19,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-duration)
+
 (ert-deftest test-org-duration/to-minutes ()
 (ert-deftest test-org-duration/to-minutes ()
   "Test `org-duration-to-minutes' specifications."
   "Test `org-duration-to-minutes' specifications."
   ;; Raise an error for unknown duration format.
   ;; Raise an error for unknown duration format.

+ 5 - 4
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
 ;; Copyright (C) 2012-2015, 2019  Nicolas Goaziou
 
 
@@ -21,8 +21,9 @@
 
 
 (eval-and-compile (require 'cl-lib))
 (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)
 (defun org-test-parse-and-interpret (text)
   "Parse TEXT as Org syntax and interpret it.
   "Parse TEXT as Org syntax and interpret it.
@@ -247,7 +248,7 @@ Some other text
     '(italic entity bold)
     '(italic entity bold)
     (org-test-with-temp-text "/some/ *paragraph*"
     (org-test-with-temp-text "/some/ *paragraph*"
       (let* ((tree (org-element-parse-buffer))
       (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)))
 	     (bold (org-element-map tree 'bold 'identity nil t)))
 	(org-element-insert-before '(entity (:name "\\alpha")) bold)
 	(org-element-insert-before '(entity (:name "\\alpha")) bold)
 	(org-element-map tree '(bold entity italic) #'org-element-type nil)))))
 	(org-element-map tree '(bold entity italic) #'org-element-type nil)))))

+ 1 - 1
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
 ;; Authors: Ihor Radchenko
 
 

+ 3 - 1
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
 ;; Copyright (C) 2012-2015, 2019  Nicolas Goaziou
 
 
@@ -19,6 +19,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-footnote)
+
 (ert-deftest test-org-footnote/new ()
 (ert-deftest test-org-footnote/new ()
   "Test `org-footnote-new' specifications."
   "Test `org-footnote-new' specifications."
   ;; `org-footnote-auto-label' is t.
   ;; `org-footnote-auto-label' is t.

+ 1 - 1
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
 ;; Copyright (c)  Marco Wahl
 ;; Authors: Marco Wahl
 ;; Authors: Marco Wahl

+ 4 - 1
testing/lisp/test-org-lint.el

@@ -19,6 +19,9 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-footnote)
+(require 'org-lint)
+
 (ert-deftest test-org-lint/add-checker ()
 (ert-deftest test-org-lint/add-checker ()
   "Test `org-lint-add-checker'."
   "Test `org-lint-add-checker'."
   ;; Name should be a non-nil symbol.
   ;; Name should be a non-nil symbol.
@@ -178,7 +181,7 @@ Paragraph 2"
   (should-not
   (should-not
    (org-test-with-temp-text "[[(foo)]]
    (org-test-with-temp-text "[[(foo)]]
 #+begin_src emacs-lisp -l \"; ref:%s\"
 #+begin_src emacs-lisp -l \"; ref:%s\"
-(+ 1 1) ; ref:foo
+\(+ 1 1) ; ref:foo
 #+end_src"
 #+end_src"
      (org-lint '(invalid-coderef-link)))))
      (org-lint '(invalid-coderef-link)))))
 
 

+ 5 - 2
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
 ;; Copyright (C) 2012, 2013, 2014, 2018, 2019  Nicolas Goaziou
 
 
@@ -19,6 +19,9 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-list)
+(require 'org)
+
 (ert-deftest test-org-list/list-ending ()
 (ert-deftest test-org-list/list-ending ()
   "Test if lists end at the right place."
   "Test if lists end at the right place."
   ;; With two blank lines.
   ;; With two blank lines.
@@ -1369,7 +1372,7 @@ b. Item 2<point>"
   ;; Sort alphabetically.
   ;; Sort alphabetically.
   (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
   (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
     (cl-letf (((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
 		 (funcall original-string-collate-lessp
 			  s1 s2 "C" ignore-case))))
 			  s1 s2 "C" ignore-case))))
       (should
       (should

+ 1 - 1
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
 ;; Copyright (C) 2013, 2014, 2019  Nicolas Goaziou
 
 

+ 3 - 1
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
 ;; Copyright (C) 2015-2016, 2019  Alexey Lebedeff
 ;; Authors: Alexey Lebedeff
 ;; Authors: Alexey Lebedeff
@@ -24,6 +24,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org)
+
 (ert-deftest test-org-pcomplete/clocktable ()
 (ert-deftest test-org-pcomplete/clocktable ()
   "Test completion of clock table parameters."
   "Test completion of clock table parameters."
   (should
   (should

+ 3 - 3
testing/lisp/test-org-protocol.el

@@ -21,9 +21,8 @@
 ;;; Code:
 ;;; Code:
 
 
 (require 'cl-lib)
 (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 ()
 (ert-deftest test-org-protocol/org-protocol-parse-parameters ()
   "Test `org-protocol-parse-parameters' specifications."
   "Test `org-protocol-parse-parameters' specifications."
@@ -241,4 +240,5 @@
 
 
 
 
 ;; TODO: Verify greedy protocol handling
 ;; TODO: Verify greedy protocol handling
+(provide 'test-org-protocol)
 ;;; test-org-protocol.el ends here
 ;;; test-org-protocol.el ends here

+ 1 - 1
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
 ;; Copyright (C) 2012-2015, 2019  Le Wang
 
 

+ 6 - 4
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
 ;; Copyright (c)  David Maus
 ;; Authors: David Maus, Michael Brand
 ;; Authors: David Maus, Michael Brand
@@ -28,6 +28,7 @@
 ;;; Code:
 ;;; Code:
 
 
 (require 'org-table)  ; `org-table-make-reference'
 (require 'org-table)  ; `org-table-make-reference'
+(require 'ox)
 
 
 (ert-deftest test-org-table/simple-formula/no-grouping/no-title-row ()
 (ert-deftest test-org-table/simple-formula/no-grouping/no-title-row ()
   "Simple sum without grouping rows, without title row."
   "Simple sum without grouping rows, without title row."
@@ -1613,7 +1614,7 @@ See also `test-org-table/copy-field'."
   (should
   (should
    (equal
    (equal
     "a\nb"
     "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-parsing-hook fun-list)
 	   (org-export-before-processing-hook fun-list))
 	   (org-export-before-processing-hook fun-list))
       (orgtbl-to-generic (org-table-to-lisp "| a |\n|---|\n| b |")
       (orgtbl-to-generic (org-table-to-lisp "| a |\n|---|\n| b |")
@@ -1622,7 +1623,8 @@ See also `test-org-table/copy-field'."
   (should
   (should
    (equal
    (equal
     "a\nb"
     "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 |")
       (orgtbl-to-generic (org-table-to-lisp "| a |\n|---|\n| b |")
 			 '(:hline nil)))))
 			 '(:hline nil)))))
   ;; Macros, even if unknown, are returned as-is.
   ;; 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.
   ;; Sort alphabetically.  Enforce the C locale for consistent results.
   (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
   (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
     (cl-letf (((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
 		 (funcall original-string-collate-lessp
 			  s1 s2 "C" ignore-case))))
 			  s1 s2 "C" ignore-case))))
       (should
       (should

+ 3 - 2
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
 ;; Copyright (C) 2014-2015, 2019  Kyle Meyer
 
 
@@ -22,12 +22,13 @@
 ;;; Code:
 ;;; Code:
 
 
 (eval-and-compile (require 'cl-lib))
 (eval-and-compile (require 'cl-lib))
+(require 'org-timer)
 
 
 (defmacro test-org-timer/with-temp-text (text &rest body)
 (defmacro test-org-timer/with-temp-text (text &rest body)
   "Like `org-test-with-temp-text', but set timer-specific variables.
   "Like `org-test-with-temp-text', but set timer-specific variables.
 Also, mute output from `message'."
 Also, mute output from `message'."
   (declare (indent 1))
   (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
      (org-test-with-temp-text ,text
        (let (org-timer-start-time
        (let (org-timer-start-time
 	     org-timer-pause-time
 	     org-timer-pause-time

+ 41 - 35
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
 ;; Copyright (c)  David Maus
 ;; Authors: David Maus
 ;; Authors: David Maus
@@ -23,6 +23,11 @@
 ;;; Code:
 ;;; Code:
 
 
 (eval-and-compile (require 'cl-lib))
 (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
 ;;; Helpers
@@ -272,6 +277,7 @@
 
 
 (ert-deftest test-org/org-read-date ()
 (ert-deftest test-org/org-read-date ()
   "Test `org-read-date' specifications."
   "Test `org-read-date' specifications."
+  (defvar org-time-was-given) ; dynamically scoped parameter
   ;; Parse ISO date with abbreviated year and month.
   ;; Parse ISO date with abbreviated year and month.
   (should (equal "2012-03-29 16:40"
   (should (equal "2012-03-29 16:40"
 		 (let ((org-time-was-given t))
 		 (let ((org-time-was-given t))
@@ -1972,7 +1978,7 @@
     "* H <2014-03-05"
     "* H <2014-03-05"
     (org-test-with-temp-text "* H <2014-03-04 Tue><point>"
     (org-test-with-temp-text "* H <2014-03-04 Tue><point>"
       (cl-letf (((symbol-function 'read-from-minibuffer)
       (cl-letf (((symbol-function 'read-from-minibuffer)
-		 (lambda (&rest args) "+1d")))
+		 (lambda (&rest _args) "+1d")))
 	(org-clone-subtree-with-time-shift 1))
 	(org-clone-subtree-with-time-shift 1))
       (buffer-substring-no-properties (line-beginning-position 2)
       (buffer-substring-no-properties (line-beginning-position 2)
 				      (line-end-position 2)))))
 				      (line-end-position 2)))))
@@ -2664,7 +2670,7 @@ SCHEDULED: <2014-03-04 tue.>"
 	      org-current-tag-alist))))
 	      org-current-tag-alist))))
   (should
   (should
    (equal '(("A" . ?a) ("B") ("C"))
    (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-test-with-temp-text "#+TAGS: A(a) B C"
 	      (org-mode-restart)
 	      (org-mode-restart)
 	      org-current-tag-alist))))
 	      org-current-tag-alist))))
@@ -3065,14 +3071,14 @@ Foo Bar
    (org-test-with-temp-text "* H :<point>tag:"
    (org-test-with-temp-text "* H :<point>tag:"
      (catch :result
      (catch :result
        (cl-letf (((symbol-function 'org-tags-view)
        (cl-letf (((symbol-function 'org-tags-view)
-		  (lambda (&rest args) (throw :result t))))
+		  (lambda (&rest _args) (throw :result t))))
 	 (org-open-at-point)
 	 (org-open-at-point)
 	 nil))))
 	 nil))))
   (should-not
   (should-not
    (org-test-with-temp-text-in-file "* H<point> :tag:"
    (org-test-with-temp-text-in-file "* H<point> :tag:"
      (catch :result
      (catch :result
        (cl-letf (((symbol-function 'org-tags-view)
        (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,
 	 ;; When point isn't on a tag it's going to try other things,
 	 ;; possibly trying to open attachments which will return an
 	 ;; possibly trying to open attachments which will return an
 	 ;; error if there isn't an attachment. Suppress that error.
 	 ;; error if there isn't an attachment. Suppress that error.
@@ -3738,7 +3744,7 @@ SCHEDULED: <2017-05-06 Sat>
   (should-not
   (should-not
    (org-test-with-temp-text "A <point>long line of text\nSome other text"
    (org-test-with-temp-text "A <point>long line of text\nSome other text"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (org-beginning-of-line)
      (org-beginning-of-line)
      (bolp)))
      (bolp)))
   ;; In a wide headline, with `visual-line-mode', prefer going to the
   ;; In a wide headline, with `visual-line-mode', prefer going to the
@@ -3747,14 +3753,14 @@ SCHEDULED: <2017-05-06 Sat>
   (should-not
   (should-not
    (org-test-with-temp-text "* A <point>long headline"
    (org-test-with-temp-text "* A <point>long headline"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (goto-char (point-max))
      (goto-char (point-max))
      (org-beginning-of-line)
      (org-beginning-of-line)
      (bobp)))
      (bobp)))
   (should-not
   (should-not
    (org-test-with-temp-text "* A <point>long headline"
    (org-test-with-temp-text "* A <point>long headline"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (goto-char (point-max))
      (goto-char (point-max))
      (let ((org-special-ctrl-a/e t)) (org-beginning-of-line))
      (let ((org-special-ctrl-a/e t)) (org-beginning-of-line))
      (bobp)))
      (bobp)))
@@ -3854,7 +3860,7 @@ SCHEDULED: <2017-05-06 Sat>
   (should-not
   (should-not
    (org-test-with-temp-text "A <point>long line of text\nSome other text"
    (org-test-with-temp-text "A <point>long line of text\nSome other text"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (goto-char (point-min))
      (goto-char (point-min))
      (org-end-of-line)
      (org-end-of-line)
      (eolp)))
      (eolp)))
@@ -3869,14 +3875,14 @@ SCHEDULED: <2017-05-06 Sat>
   (should-not
   (should-not
    (org-test-with-temp-text "* A <point>long headline"
    (org-test-with-temp-text "* A <point>long headline"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (goto-char (point-min))
      (goto-char (point-min))
      (org-end-of-line)
      (org-end-of-line)
      (eolp)))
      (eolp)))
   (should-not
   (should-not
    (org-test-with-temp-text "* A <point>long headline :tag:"
    (org-test-with-temp-text "* A <point>long headline :tag:"
      (visual-line-mode)
      (visual-line-mode)
-     (dotimes (i 1000) (insert "very "))
+     (dotimes (_ 1000) (insert "very "))
      (goto-char (point-min))
      (goto-char (point-min))
      (org-end-of-line)
      (org-end-of-line)
      (eolp)))
      (eolp)))
@@ -5629,7 +5635,7 @@ Paragraph<point>"
   (should
   (should
    (equal "* H\nDEADLINE: <2012-03-29 -705d>"
    (equal "* H\nDEADLINE: <2012-03-29 -705d>"
 	  (cl-letf (((symbol-function 'org-read-date)
 	  (cl-letf (((symbol-function 'org-read-date)
-		     (lambda (&rest args)
+		     (lambda (&rest _args)
 		       (org-time-string-to-time "2014-03-04"))))
 		       (org-time-string-to-time "2014-03-04"))))
 	    (org-test-with-temp-text "* H\nDEADLINE: <2012-03-29>"
 	    (org-test-with-temp-text "* H\nDEADLINE: <2012-03-29>"
 	      (let ((org-adapt-indentation nil)
 	      (let ((org-adapt-indentation nil)
@@ -5638,7 +5644,7 @@ Paragraph<point>"
 	      (buffer-string)))))
 	      (buffer-string)))))
   (should-error
   (should-error
    (cl-letf (((symbol-function 'org-read-date)
    (cl-letf (((symbol-function 'org-read-date)
-	      (lambda (&rest args)
+	      (lambda (&rest _args)
 		(org-time-string-to-time "2014-03-04"))))
 		(org-time-string-to-time "2014-03-04"))))
      (org-test-with-temp-text "* H"
      (org-test-with-temp-text "* H"
        (let ((org-adapt-indentation nil)
        (let ((org-adapt-indentation nil)
@@ -5741,7 +5747,7 @@ Paragraph<point>"
   (should
   (should
    (equal "* H\nSCHEDULED: <2012-03-29 -705d>"
    (equal "* H\nSCHEDULED: <2012-03-29 -705d>"
 	  (cl-letf (((symbol-function 'org-read-date)
 	  (cl-letf (((symbol-function 'org-read-date)
-		     (lambda (&rest args)
+		     (lambda (&rest _args)
 		       (org-time-string-to-time "2014-03-04"))))
 		       (org-time-string-to-time "2014-03-04"))))
 	    (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
 	    (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
 	      (let ((org-adapt-indentation nil)
 	      (let ((org-adapt-indentation nil)
@@ -5750,7 +5756,7 @@ Paragraph<point>"
 	      (buffer-string)))))
 	      (buffer-string)))))
   (should-error
   (should-error
    (cl-letf (((symbol-function 'org-read-date)
    (cl-letf (((symbol-function 'org-read-date)
-	      (lambda (&rest args)
+	      (lambda (&rest _args)
 		(org-time-string-to-time "2014-03-04"))))
 		(org-time-string-to-time "2014-03-04"))))
      (org-test-with-temp-text "* H"
      (org-test-with-temp-text "* H"
        (let ((org-adapt-indentation nil)
        (let ((org-adapt-indentation nil)
@@ -7307,7 +7313,7 @@ Paragraph<point>"
    (equal "* H1 :foo:"
    (equal "* H1 :foo:"
 	  (org-test-with-temp-text "* H1"
 	  (org-test-with-temp-text "* H1"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7317,7 +7323,7 @@ Paragraph<point>"
    (equal "* H1 :foo:\nContents"
    (equal "* H1 :foo:\nContents"
 	  (org-test-with-temp-text "* H1\n<point>Contents"
 	  (org-test-with-temp-text "* H1\n<point>Contents"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7326,7 +7332,7 @@ Paragraph<point>"
    (equal "* H1 :foo:\nContents2"
    (equal "* H1 :foo:\nContents2"
 	  (org-test-with-temp-text "* H1\n<point>Contents2"
 	  (org-test-with-temp-text "* H1\n<point>Contents2"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7338,7 +7344,7 @@ Paragraph<point>"
    (equal "* H1 :foo:\nContents\n* H2 :foo:"
    (equal "* H1 :foo:\nContents\n* H2 :foo:"
 	  (org-test-with-temp-text "* H1\nContents\n* H2"
 	  (org-test-with-temp-text "* H1\nContents\n* H2"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-loop-over-headlines-in-active-region t)
 		    (org-loop-over-headlines-in-active-region t)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
@@ -7351,7 +7357,7 @@ Paragraph<point>"
    (equal "* H1\nContents\n* H2 :foo:"
    (equal "* H1\nContents\n* H2 :foo:"
 	  (org-test-with-temp-text "* H1\nContents\n* H2"
 	  (org-test-with-temp-text "* H1\nContents\n* H2"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-loop-over-headlines-in-active-region nil)
 		    (org-loop-over-headlines-in-active-region nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
@@ -7371,7 +7377,7 @@ Paragraph<point>"
    (equal ":foo:"
    (equal ":foo:"
 	  (org-test-with-temp-text "* <point>"
 	  (org-test-with-temp-text "* <point>"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7381,7 +7387,7 @@ Paragraph<point>"
    (equal "* H1 :foo:"
    (equal "* H1 :foo:"
 	  (org-test-with-temp-text "* H1"
 	  (org-test-with-temp-text "* H1"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7391,7 +7397,7 @@ Paragraph<point>"
    (equal "* H1 :foo:"
    (equal "* H1 :foo:"
 	  (org-test-with-temp-text "*<point>* H1"
 	  (org-test-with-temp-text "*<point>* H1"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7401,7 +7407,7 @@ Paragraph<point>"
    (equal " b :foo:"
    (equal " b :foo:"
 	  (org-test-with-temp-text "* a<point> b"
 	  (org-test-with-temp-text "* a<point> b"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (cl-letf (((symbol-function 'completing-read-multiple)
-		       (lambda (&rest args) '("foo"))))
+		       (lambda (&rest _args) '("foo"))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
 		(org-set-tags-command)))
 		(org-set-tags-command)))
@@ -7411,7 +7417,7 @@ Paragraph<point>"
    (equal "b :foo:"
    (equal "b :foo:"
 	  (org-test-with-temp-text "* a :foo:\n** <point>b :foo:"
 	  (org-test-with-temp-text "* a :foo:\n** <point>b :foo:"
 	    (cl-letf (((symbol-function 'completing-read-multiple)
 	    (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))))
 			 (list initial))))
 	      (let ((org-use-fast-tag-selection nil)
 	      (let ((org-use-fast-tag-selection nil)
 		    (org-tags-column 1))
 		    (org-tags-column 1))
@@ -7687,7 +7693,7 @@ Paragraph<point>"
     (let ((org-todo-keywords '((sequence "TODO" "DONE")))
     (let ((org-todo-keywords '((sequence "TODO" "DONE")))
 	  (org-log-repeat nil))
 	  (org-log-repeat nil))
       (cl-letf (((symbol-function 'org-add-log-setup)
       (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-test-with-temp-text "* TODO H\n<2012-03-29 Thu. +2y>"
 	  (org-todo "DONE")
 	  (org-todo "DONE")
 	  (buffer-string))))))
 	  (buffer-string))))))
@@ -7697,7 +7703,7 @@ Paragraph<point>"
     (let ((org-todo-keywords '((sequence "TODO" "DONE")))
     (let ((org-todo-keywords '((sequence "TODO" "DONE")))
 	  (org-log-repeat t))
 	  (org-log-repeat t))
       (cl-letf (((symbol-function 'org-add-log-setup)
       (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-test-with-temp-text "* TODO H\n<2012-03-29 Thu. +2y>"
 	  (org-todo "DONE")
 	  (org-todo "DONE")
 	  (buffer-string))))))
 	  (buffer-string))))))
@@ -7706,7 +7712,7 @@ Paragraph<point>"
     ":LAST_REPEAT:"
     ":LAST_REPEAT:"
     (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
     (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
       (cl-letf (((symbol-function 'org-add-log-setup)
       (cl-letf (((symbol-function 'org-add-log-setup)
-		 (lambda (&rest args) nil)))
+		 (lambda (&rest _args) nil)))
 	(org-test-with-temp-text
 	(org-test-with-temp-text
 	    "* TODO H\n<2012-03-29 Thu +2y>\nCLOCK: [2012-03-29 Thu 16:40]"
 	    "* TODO H\n<2012-03-29 Thu +2y>\nCLOCK: [2012-03-29 Thu 16:40]"
 	  (org-todo "DONE")
 	  (org-todo "DONE")
@@ -8016,7 +8022,7 @@ CLOSED: %s
     "Te<2014-03-04 .*?>xt"
     "Te<2014-03-04 .*?>xt"
     (org-test-with-temp-text "Te<point>xt"
     (org-test-with-temp-text "Te<point>xt"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(org-time-stamp nil)
 	(org-time-stamp nil)
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8026,7 +8032,7 @@ CLOSED: %s
     "Te<2014-03-04 .*? 00:41>xt"
     "Te<2014-03-04 .*? 00:41>xt"
     (org-test-with-temp-text "Te<point>xt"
     (org-test-with-temp-text "Te<point>xt"
       (cl-letf (((symbol-function 'org-read-date)
       (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-string-to-time "2014-03-04 00:41"))))
 	(org-time-stamp '(4))
 	(org-time-stamp '(4))
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8045,7 +8051,7 @@ CLOSED: %s
     "Te\\[2014-03-04 .*?\\]xt"
     "Te\\[2014-03-04 .*?\\]xt"
     (org-test-with-temp-text "Te<point>xt"
     (org-test-with-temp-text "Te<point>xt"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(org-time-stamp nil t)
 	(org-time-stamp nil t)
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8055,7 +8061,7 @@ CLOSED: %s
     "<2014-03-04 .*?>"
     "<2014-03-04 .*?>"
     (org-test-with-temp-text "<2012-03-29<point> thu.>"
     (org-test-with-temp-text "<2012-03-29<point> thu.>"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(org-time-stamp nil)
 	(org-time-stamp nil)
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8064,7 +8070,7 @@ CLOSED: %s
     "<2014-03-04 .*?>--<2014-03-04 .*?>"
     "<2014-03-04 .*?>--<2014-03-04 .*?>"
     (org-test-with-temp-text "<2012-03-29<point> thu.>--<2014-03-04 tue.>"
     (org-test-with-temp-text "<2012-03-29<point> thu.>--<2014-03-04 tue.>"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(org-time-stamp nil)
 	(org-time-stamp nil)
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8074,7 +8080,7 @@ CLOSED: %s
     "<2014-03-04 .*? \\+2y>"
     "<2014-03-04 .*? \\+2y>"
     (org-test-with-temp-text "<2012-03-29<point> thu. +2y>"
     (org-test-with-temp-text "<2012-03-29<point> thu. +2y>"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(org-time-stamp nil)
 	(org-time-stamp nil)
 	(buffer-string)))))
 	(buffer-string)))))
@@ -8084,7 +8090,7 @@ CLOSED: %s
     "<2012-03-29 .*?>--<2014-03-04 .*?>"
     "<2012-03-29 .*?>--<2014-03-04 .*?>"
     (org-test-with-temp-text "<2012-03-29 thu.><point>"
     (org-test-with-temp-text "<2012-03-29 thu.><point>"
       (cl-letf (((symbol-function 'org-read-date)
       (cl-letf (((symbol-function 'org-read-date)
-		 (lambda (&rest args)
+		 (lambda (&rest _args)
 		   (org-time-string-to-time "2014-03-04"))))
 		   (org-time-string-to-time "2014-03-04"))))
 	(let ((last-command 'org-time-stamp)
 	(let ((last-command 'org-time-stamp)
 	      (this-command 'org-time-stamp))
 	      (this-command 'org-time-stamp))

+ 15 - 13
testing/lisp/test-ox-publish.el

@@ -19,6 +19,8 @@
 
 
 ;;; Code:
 ;;; Code:
 
 
+(require 'org-test "../testing/org-test")
+(require 'ox-publish)
 
 
 ;;; Helper functions
 ;;; Helper functions
 
 
@@ -354,20 +356,20 @@ removed from the final plist."
   (should
   (should
    (apply
    (apply
     #'equal
     #'equal
-    (let* ((ids nil)
+    (let* (;; (ids nil)
 	   (backend
 	   (backend
 	    (org-export-create-backend
 	    (org-export-create-backend
 	     :transcoders
 	     :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
 	   (publish
 	    (lambda (plist filename pub-dir)
 	    (lambda (plist filename pub-dir)
 	      (org-publish-org-to backend filename ".test" plist pub-dir))))
 	      (org-publish-org-to backend filename ".test" plist pub-dir))))
@@ -387,7 +389,7 @@ removed from the final plist."
     '("a1" "b1")
     '("a1" "b1")
     (let* ((ids nil)
     (let* ((ids nil)
 	   (link-transcoder
 	   (link-transcoder
-	    (lambda (l c i)
+	    (lambda (l _c _i)
 	      (let ((option (org-element-property :search-option l))
 	      (let ((option (org-element-property :search-option l))
 		    (path (org-element-property :path l)))
 		    (path (org-element-property :path l)))
 		(push (org-publish-resolve-external-link option path t)
 		(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.
   ;; Return nil if no appropriate project is found.
   (should-not
   (should-not
    (let* ((base (expand-file-name "examples/pub/" org-test-dir))
    (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-project-alist `(("p" :base-directory ,base))))
      (org-publish-get-project-from-filename "/other/file.org")))
      (org-publish-get-project-from-filename "/other/file.org")))
   ;; Return the first project effectively publishing the provided
   ;; Return the first project effectively publishing the provided

+ 24 - 21
testing/lisp/test-ox.el

@@ -22,9 +22,8 @@
 ;;; Code:
 ;;; Code:
 
 
 (require 'cl-lib)
 (require 'cl-lib)
-
-(unless (featurep 'ox)
-  (signal 'missing-test-dependency "org-export"))
+(require 'ox)
+(require 'org-inlinetask)
 
 
 (defun org-test-default-backend ()
 (defun org-test-default-backend ()
   "Return a default export back-end.
   "Return a default export back-end.
@@ -55,6 +54,7 @@ variable, and communication channel under `info'."
        (org-export--remove-uninterpreted-data tree info)
        (org-export--remove-uninterpreted-data tree info)
        (let ((info (org-combine-plists
        (let ((info (org-combine-plists
 		    info (org-export--collect-tree-properties tree info))))
 		    info (org-export--collect-tree-properties tree info))))
+	 (ignore info) ;; Don't warn if the var is unused.
 	 ,@body))))
 	 ,@body))))
 
 
 
 
@@ -93,6 +93,7 @@ variable, and communication channel under `info'."
        (format "#+SETUPFILE: \"%s/examples/setupfile.org\"" org-test-dir)
        (format "#+SETUPFILE: \"%s/examples/setupfile.org\"" org-test-dir)
      (let ((org-export-allow-bind-keywords t))
      (let ((org-export-allow-bind-keywords t))
        (org-export-get-environment)
        (org-export-get-environment)
+       ;; FIXME: `variable'?
        (eq variable 'value))))
        (eq variable 'value))))
   ;; Verify that bound variables are seen during export.
   ;; Verify that bound variables are seen during export.
   (should
   (should
@@ -2002,11 +2003,11 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
 		 (org-export-create-backend
 		 (org-export-create-backend
 		  :transcoders
 		  :transcoders
 		  (list (cons 'headline
 		  (list (cons 'headline
-			      (lambda (headline contents info)
+			      (lambda (headline _contents info)
 				(org-export-data
 				(org-export-data
 				 (org-element-property :title headline)
 				 (org-element-property :title headline)
 				 info)))
 				 info)))
-			(cons 'plain-text (lambda (text info) "Success"))))))
+			(cons 'plain-text (lambda (_text _info) "Success"))))))
 	    (org-export-string-as
 	    (org-export-string-as
 	     "* Test"
 	     "* Test"
 	     (org-export-create-backend
 	     (org-export-create-backend
@@ -2143,7 +2144,7 @@ Para2"
       (setf (org-export-backend-name backend) 'test)
       (setf (org-export-backend-name backend) 'test)
       (setf (org-export-backend-transcoders backend)
       (setf (org-export-backend-transcoders backend)
 	    (cons (cons 'export-snippet
 	    (cons (cons 'export-snippet
-			(lambda (snippet contents info)
+			(lambda (snippet _contents _info)
 			  (when (eq (org-export-snippet-backend snippet) 'test)
 			  (when (eq (org-export-snippet-backend snippet) 'test)
 			    (org-element-property :value snippet))))
 			    (org-element-property :value snippet))))
 		  (org-export-backend-transcoders backend)))
 		  (org-export-backend-transcoders backend)))
@@ -2190,15 +2191,15 @@ Para2"
   (should
   (should
    (equal ""
    (equal ""
 	  (org-export-filter-apply-functions
 	  (org-export-filter-apply-functions
-	   (list (lambda (value &rest _) "")
+	   (list (lambda (_value &rest _) "")
 		 (lambda (value &rest _) (concat "2" value)))
 		 (lambda (value &rest _) (concat "2" value)))
 	   "0" nil)))
 	   "0" nil)))
   ;; Any function returning the empty string short-circuits the
   ;; Any function returning the empty string short-circuits the
   ;; process.
   ;; process.
   (should
   (should
    (org-export-filter-apply-functions
    (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)))
     "0" nil)))
 
 
 
 
@@ -2215,7 +2216,7 @@ Para2"
 	 (org-export-create-backend
 	 (org-export-create-backend
 	  :transcoders
 	  :transcoders
 	  `(,(cons 'footnote-reference
 	  `(,(cons 'footnote-reference
-		   (lambda (f c i)
+		   (lambda (f _c i)
 		     (push (org-export-footnote-first-reference-p f i)
 		     (push (org-export-footnote-first-reference-p f i)
 			   result)
 			   result)
 		     ""))
 		     ""))
@@ -2260,7 +2261,7 @@ Para2"
 	 (org-export-create-backend
 	 (org-export-create-backend
 	  :transcoders
 	  :transcoders
 	  `(,(cons 'footnote-reference
 	  `(,(cons 'footnote-reference
-		   (lambda (f c i)
+		   (lambda (f _c i)
 		     (when (org-element-lineage f '(drawer))
 		     (when (org-element-lineage f '(drawer))
 		       (push (org-export-footnote-first-reference-p f i nil)
 		       (push (org-export-footnote-first-reference-p f i nil)
 			     result))
 			     result))
@@ -2281,7 +2282,7 @@ Para2"
 	 (org-export-create-backend
 	 (org-export-create-backend
 	  :transcoders
 	  :transcoders
 	  `(,(cons 'footnote-reference
 	  `(,(cons 'footnote-reference
-		   (lambda (f c i)
+		   (lambda (f _c i)
 		     (when (org-element-lineage f '(drawer))
 		     (when (org-element-lineage f '(drawer))
 		       (push (org-export-footnote-first-reference-p f i nil t)
 		       (push (org-export-footnote-first-reference-p f i nil t)
 			     result))
 			     result))
@@ -2979,7 +2980,7 @@ Para2"
    (string-match
    (string-match
     "success"
     "success"
     (progn
     (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
       (org-export-string-as
        "[[foo:path]]"
        "[[foo:path]]"
        (org-export-create-backend
        (org-export-create-backend
@@ -2995,7 +2996,7 @@ Para2"
     "success"
     "success"
     (progn
     (progn
       (org-link-set-parameters
       (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
       (org-export-string-as
        "[[foo:path]]"
        "[[foo:path]]"
        (org-export-create-backend
        (org-export-create-backend
@@ -3012,7 +3013,7 @@ Para2"
     "success"
     "success"
     (progn
     (progn
       (org-link-set-parameters
       (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
       (org-export-string-as
        "[[foo:path]]"
        "[[foo:path]]"
        (org-export-create-backend
        (org-export-create-backend
@@ -5043,7 +5044,8 @@ This test does not cover listings and custom environments."
 	 (org-element-type
 	 (org-element-type
 	  (org-export-get-next-element
 	  (org-export-get-next-element
 	   (org-element-map
 	   (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.
   ;; Find next element in parsed affiliated keywords.
   (should
   (should
    (eq 'verbatim
    (eq 'verbatim
@@ -5057,7 +5059,7 @@ This test does not cover listings and custom environments."
    (equal
    (equal
     '(bold code underline)
     '(bold code underline)
     (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
     (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
-      (mapcar 'car
+      (mapcar #'car
 	      (org-export-get-next-element
 	      (org-export-get-next-element
 	       (org-element-map tree 'italic 'identity info t) info t)))))
 	       (org-element-map tree 'italic 'identity info t) info t)))))
   ;; When N is a positive integer, return a list containing up to
   ;; 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
    (equal
     '(bold code)
     '(bold code)
     (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
     (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
-      (mapcar 'car
+      (mapcar #'car
 	      (org-export-get-next-element
 	      (org-export-get-next-element
 	       (org-element-map tree 'italic 'identity info t) info 2))))))
 	       (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-element-type
 	  (org-export-get-previous-element
 	  (org-export-get-previous-element
 	   (org-element-map
 	   (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.
   ;; Find previous element in parsed affiliated keywords.
   (should
   (should
    (eq 'verbatim
    (eq 'verbatim
@@ -5122,7 +5125,7 @@ This test does not cover listings and custom environments."
   (should
   (should
    (equal '(underline italic bold)
    (equal '(underline italic bold)
 	  (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
 	  (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
-	    (mapcar 'car
+	    (mapcar #'car
 		    (org-export-get-previous-element
 		    (org-export-get-previous-element
 		     (org-element-map tree 'code 'identity info t) info t)))))
 		     (org-element-map tree 'code 'identity info t) info t)))))
   ;; When N is a positive integer, return a list containing up to
   ;; 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
   (should
    (equal '(italic bold)
    (equal '(italic bold)
 	  (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
 	  (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
-	    (mapcar 'car
+	    (mapcar #'car
 		    (org-export-get-previous-element
 		    (org-export-get-previous-element
 		     (org-element-map tree 'code 'identity info t) info 2))))))
 		     (org-element-map tree 'code 'identity info t) info 2))))))
 
 

+ 1 - 1
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
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
 ;; Authors: Eric Schulte

+ 9 - 7
testing/org-batch-test-init.el

@@ -1,4 +1,4 @@
-;;
+;;  -*- lexical-binding: t; -*-
 ;; Remove Org remnants built into Emacs
 ;; Remove Org remnants built into Emacs
 ;;
 ;;
 
 
@@ -10,11 +10,13 @@
 		     p))
 		     p))
 		 load-path)))
 		 load-path)))
 ;; remove property list to defeat cus-load and remove autoloads
 ;; 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
 ;; we should now start from a clean slate

+ 26 - 24
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
 ;; Copyright (c) 2010-2015 Sebastian Rose, Eric Schulte
 ;; Authors:
 ;; Authors:
@@ -31,6 +31,9 @@
 
 
 ;;;; Code:
 ;;;; Code:
 
 
+(require 'org)
+(require 'org-id)
+
 ;;; Ob constants
 ;;; Ob constants
 
 
 (defconst org-test-file-ob-anchor
 (defconst org-test-file-ob-anchor
@@ -75,7 +78,7 @@ org-test searches this directory up the directory tree.")
 (defconst org-test-dir
 (defconst org-test-dir
   (expand-file-name (file-name-directory (or load-file-name buffer-file-name))))
   (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))
   (expand-file-name ".." org-test-dir))
 
 
 (defconst org-test-example-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
 (defconst org-test-link-in-heading-file
   (expand-file-name "link-in-heading.org" org-test-dir))
   (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))
   (expand-file-name ".test-org-id-locations" org-test-dir))
 
 
 
 
 ;;; Functions for writing tests
 ;;; Functions for writing tests
-(put 'missing-test-dependency
+(put 'missing-test-dependency           ;FIXME: Use `define-error'.
      'error-conditions
      'error-conditions
      '(error missing-test-dependency))
      '(error missing-test-dependency))
 
 
@@ -113,18 +117,18 @@ executable."
 	   exec-path :initial-value nil)
 	   exec-path :initial-value nil)
     (signal 'missing-test-dependency (list exe))))
     (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.
   "TODO:  Setup and return a buffer to work with.
 If file is non-nil insert its contents in there.")
 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.
   "TODO:  Compare the contents of the test buffer with FILE.
 If file is not given, search for a file named after the test
 If file is not given, search for a file named after the test
 currently executed.")
 currently executed.")
 
 
 (defmacro org-test-at-id (id &rest body)
 (defmacro org-test-at-id (id &rest body)
   "Run body after placing the point in the headline identified by ID."
   "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))
   `(let* ((id-location (org-id-find ,id))
 	  (id-file (car id-location))
 	  (id-file (car id-location))
 	  (visited-p (get-file-buffer id-file))
 	  (visited-p (get-file-buffer id-file))
@@ -142,11 +146,10 @@ currently executed.")
 	     (save-restriction ,@body)))
 	     (save-restriction ,@body)))
        (unless (or visited-p (not to-be-removed))
        (unless (or visited-p (not to-be-removed))
 	 (kill-buffer 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)
 (defmacro org-test-in-example-file (file &rest body)
   "Execute body in the Org example file."
   "Execute body in the Org example file."
-  (declare (indent 1))
+  (declare (indent 1) (debug t))
   `(let* ((my-file (or ,file org-test-file))
   `(let* ((my-file (or ,file org-test-file))
 	  (visited-p (get-file-buffer my-file))
 	  (visited-p (get-file-buffer my-file))
 	  to-be-removed
 	  to-be-removed
@@ -168,26 +171,24 @@ currently executed.")
      (unless visited-p
      (unless visited-p
        (kill-buffer to-be-removed))
        (kill-buffer to-be-removed))
      results))
      results))
-(def-edebug-spec org-test-in-example-file (form body))
 
 
 (defmacro org-test-at-marker (file marker &rest body)
 (defmacro org-test-at-marker (file marker &rest body)
   "Run body after placing the point at MARKER in FILE.
   "Run body after placing the point at MARKER in FILE.
 Note the uuidgen command-line command can be useful for
 Note the uuidgen command-line command can be useful for
 generating unique markers for insertion as anchors into org
 generating unique markers for insertion as anchors into org
 files."
 files."
-  (declare (indent 2))
+  (declare (indent 2) (debug t))
   `(org-test-in-example-file ,file
   `(org-test-in-example-file ,file
      (goto-char (point-min))
      (goto-char (point-min))
      (re-search-forward (regexp-quote ,marker))
      (re-search-forward (regexp-quote ,marker))
      ,@body))
      ,@body))
-(def-edebug-spec org-test-at-marker (form form body))
 
 
 (defmacro org-test-with-temp-text (text &rest body)
 (defmacro org-test-with-temp-text (text &rest body)
   "Run body in a temporary buffer with Org mode as the active
   "Run body in a temporary buffer with Org mode as the active
 mode holding TEXT.  If the string \"<point>\" appears in TEXT
 mode holding TEXT.  If the string \"<point>\" appears in TEXT
 then remove it and place the point there before running BODY,
 then remove it and place the point there before running BODY,
 otherwise place the point at the beginning of the inserted text."
 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)))
   `(let ((inside-text (if (stringp ,text) ,text (eval ,text)))
 	 (org-mode-hook nil))
 	 (org-mode-hook nil))
      (with-temp-buffer
      (with-temp-buffer
@@ -201,20 +202,21 @@ otherwise place the point at the beginning of the inserted text."
 	   (goto-char (point-min))))
 	   (goto-char (point-min))))
        (font-lock-ensure (point-min) (point-max))
        (font-lock-ensure (point-min) (point-max))
        ,@body)))
        ,@body)))
-(def-edebug-spec org-test-with-temp-text (form body))
 
 
 (defmacro org-test-with-temp-text-in-file (text &rest 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.
   "Run body in a temporary file buffer with Org mode as the active mode.
 If the string \"<point>\" appears in TEXT then remove it and
 If the string \"<point>\" appears in TEXT then remove it and
 place the point there before running BODY, otherwise place the
 place the point there before running BODY, otherwise place the
 point at the beginning of the buffer."
 point at the beginning of the buffer."
-  (declare (indent 1))
+  (declare (indent 1) (debug t))
   `(let ((file (make-temp-file "org-test"))
   `(let ((file (make-temp-file "org-test"))
 	 (inside-text (if (stringp ,text) ,text (eval ,text)))
 	 (inside-text (if (stringp ,text) ,text (eval ,text)))
 	 buffer)
 	 buffer)
      (with-temp-file file (insert inside-text))
      (with-temp-file file (insert inside-text))
      (unwind-protect
      (unwind-protect
 	 (progn
 	 (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))
 	   (setq buffer (find-file file))
 	   (when (re-search-forward "<point>" nil t)
 	   (when (re-search-forward "<point>" nil t)
 	     (replace-match ""))
 	     (replace-match ""))
@@ -228,15 +230,13 @@ point at the beginning of the buffer."
 	   (set-buffer-modified-p nil)
 	   (set-buffer-modified-p nil)
 	   (kill-buffer))
 	   (kill-buffer))
 	 (delete-file file)))))
 	 (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.
   "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
 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
 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
 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
 but this will run one recalculation longer.  When EXPECT is nil
 it will be set to TARGET.
 it will be set to TARGET.
 
 
@@ -291,6 +291,8 @@ setting `pp-escape-newlines' to nil manually."
      (env-def (funcall body env-def))
      (env-def (funcall body env-def))
      ((eq system-type 'windows-nt) (funcall body null-device))
      ((eq system-type 'windows-nt) (funcall body null-device))
      (t (require 'tramp)
      (t (require 'tramp)
+        (defvar tramp-methods)
+        (defvar tramp-default-host-alist)
         (let ((tramp-methods
         (let ((tramp-methods
                (cons '("mock"
                (cons '("mock"
                        (tramp-login-program        "sh")
                        (tramp-login-program        "sh")
@@ -321,7 +323,7 @@ Tramp related features.  We mostly follow
   (let ((exp `(progn ,@body)))
   (let ((exp `(progn ,@body)))
     (if (eval test t)
     (if (eval test t)
         exp
         exp
-      `(when ,test (eval exp t)))))
+      `(when ,test (eval ',exp t)))))
 
 
 (org--compile-when (featurep 'jump)
 (org--compile-when (featurep 'jump)
   (defjump org-test-jump
   (defjump org-test-jump
@@ -364,7 +366,7 @@ Tramp related features.  We mostly follow
 	full-path))
 	full-path))
     (lambda () ((lambda (res) (if (listp res) (car res) res)) (which-function)))))
     (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
 ;;; Miscellaneous helper functions
@@ -399,8 +401,8 @@ Tramp related features.  We mostly follow
 	       (lambda (path)
 	       (lambda (path)
 		 (if (file-directory-p path)
 		 (if (file-directory-p path)
 		     (rld 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))
 					   (file-name-nondirectory path))
                          (let ((feature-name
                          (let ((feature-name
                                 (intern
                                 (intern
@@ -415,7 +417,7 @@ Tramp related features.  We mostly follow
 			(eval `(ert-deftest ,name ()
 			(eval `(ert-deftest ,name ()
 				 :expected-result :failed (should nil))))))))
 				 :expected-result :failed (should nil))))))))
 	       (directory-files base 'full
 	       (directory-files base 'full
-				"^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$"))))
+			        "\\`\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el\\'"))))
     (rld (expand-file-name "lisp" org-test-dir))))
     (rld (expand-file-name "lisp" org-test-dir))))
 
 
 (defun org-test-current-defun ()
 (defun org-test-current-defun ()