emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Use lexical-scoping in tests
@ 2022-09-13  0:05 Stefan Monnier
  2022-09-14 12:32 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2022-09-13  0:05 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

The patch below simply enables `lexical-binding` in all the test files.
As far as I can tell, it's all that's needed (beside a missing
`require`).


        Stefan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org.patch --]
[-- Type: text/x-diff, Size: 17338 bytes --]

diff --git a/testing/examples/babel.el b/testing/examples/babel.el
index a7bb0ccf52..cbd522e243 100644
--- a/testing/examples/babel.el
+++ b/testing/examples/babel.el
@@ -1,3 +1,4 @@
+;; -*- lexical-binding: t; -*-
 (string-match-p "^#[[:digit:]]+$" "#123")
 
 ;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]
diff --git a/testing/lisp/test-ob-C.el b/testing/lisp/test-ob-C.el
index 5f1dd1acb7..793ca31684 100644
--- a/testing/lisp/test-ob-C.el
+++ b/testing/lisp/test-ob-C.el
@@ -1,4 +1,4 @@
-;;; test-ob-C.el --- tests for ob-C.el
+;;; test-ob-C.el --- tests for ob-C.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov, Thierry Banel
 ;; Authors: Sergey Litvinov, Thierry Banel
diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el
index 1e60ae903f..98d73dea91 100644
--- a/testing/lisp/test-ob-R.el
+++ b/testing/lisp/test-ob-R.el
@@ -1,4 +1,4 @@
-;;; test-ob-R.el --- tests for ob-R.el
+;;; test-ob-R.el --- tests for ob-R.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el
index 21151b21fc..874d2c0268 100644
--- a/testing/lisp/test-ob-awk.el
+++ b/testing/lisp/test-ob-awk.el
@@ -1,4 +1,4 @@
-;;; test-ob-awk.el --- tests for ob-awk.el
+;;; test-ob-awk.el --- tests for ob-awk.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
diff --git a/testing/lisp/test-ob-clojure.el b/testing/lisp/test-ob-clojure.el
index 609fc0ea85..3a21498b4a 100644
--- a/testing/lisp/test-ob-clojure.el
+++ b/testing/lisp/test-ob-clojure.el
@@ -1,4 +1,4 @@
-;;; test-ob-clojure.el
+;;; test-ob-clojure.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
 ;; Authors: stardiviner
diff --git a/testing/lisp/test-ob-emacs-lisp.el b/testing/lisp/test-ob-emacs-lisp.el
index e7b85d5ba5..c7bf17784b 100644
--- a/testing/lisp/test-ob-emacs-lisp.el
+++ b/testing/lisp/test-ob-emacs-lisp.el
@@ -1,4 +1,4 @@
-;;; test-ob-emacs-lisp.el
+;;; test-ob-emacs-lisp.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2012-2022 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte, Martyn Jago
diff --git a/testing/lisp/test-ob-eshell.el b/testing/lisp/test-ob-eshell.el
index d74742690b..4430a21c7a 100644
--- a/testing/lisp/test-ob-eshell.el
+++ b/testing/lisp/test-ob-eshell.el
@@ -1,4 +1,4 @@
-;;; test-ob-eshell.el
+;;; test-ob-eshell.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2018 stardiviner
 ;; Authors: stardiviner
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index 1289745aea..b85db33401 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -1,4 +1,4 @@
-;;; test-ob-exp.el
+;;; test-ob-exp.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el
index 79a35d58e8..3f821e4dac 100644
--- a/testing/lisp/test-ob-fortran.el
+++ b/testing/lisp/test-ob-fortran.el
@@ -1,4 +1,4 @@
-;;; test-ob-fortran.el --- tests for ob-fortran.el
+;;; test-ob-fortran.el --- tests for ob-fortran.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
diff --git a/testing/lisp/test-ob-header-arg-defaults.el b/testing/lisp/test-ob-header-arg-defaults.el
index 1106892d55..beb3ea5b8a 100644
--- a/testing/lisp/test-ob-header-arg-defaults.el
+++ b/testing/lisp/test-ob-header-arg-defaults.el
@@ -1,4 +1,4 @@
-;;; test-ob-header-arg-defaults.el --- tests for default header args from properties
+;;; test-ob-header-arg-defaults.el --- tests for default header args from properties  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2013, 2014, 2019 Achim Gratz
 ;; Authors: Achim Gratz
diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el
index 56ced23740..1a79fc66a1 100644
--- a/testing/lisp/test-ob-java.el
+++ b/testing/lisp/test-ob-java.el
@@ -1,4 +1,4 @@
-;;; test-ob-java.el --- tests for ob-java.el
+;;; test-ob-java.el --- tests for ob-java.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2020-2022 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-julia.el b/testing/lisp/test-ob-julia.el
index f6d21726aa..b25235f5fa 100644
--- a/testing/lisp/test-ob-julia.el
+++ b/testing/lisp/test-ob-julia.el
@@ -1,4 +1,4 @@
-;;; test-ob-python.el --- tests for ob-python.el
+;;; test-ob-python.el --- tests for ob-python.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2011-2014, 2019, 2021 Eric Schulte
 ;; Authors: Pedro Bruel, based on test-ob-python.el by Eric Schulte
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
index 1c1d73309e..2c764a05b6 100644
--- a/testing/lisp/test-ob-lilypond.el
+++ b/testing/lisp/test-ob-lilypond.el
@@ -1,4 +1,4 @@
-;;; test-ob-lilypond.el --- tests for ob-lilypond.el
+;;; test-ob-lilypond.el --- tests for ob-lilypond.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Martyn Jago
 ;; Authors: Martyn Jago
diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el
index c661d5a3eb..0e69bef15f 100644
--- a/testing/lisp/test-ob-lob.el
+++ b/testing/lisp/test-ob-lob.el
@@ -1,4 +1,4 @@
-;;; test-ob-lob.el --- test for ob-lob.el
+;;; test-ob-lob.el --- test for ob-lob.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el
index 7d82dd923c..f30e65bb39 100644
--- a/testing/lisp/test-ob-lua.el
+++ b/testing/lisp/test-ob-lua.el
@@ -1,4 +1,4 @@
-;;; test-ob-lua.el --- tests for ob-lua.el
+;;; test-ob-lua.el --- tests for ob-lua.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2016, 2019 Thibault Marin
 ;; Authors: Thibault Marin
diff --git a/testing/lisp/test-ob-maxima.el b/testing/lisp/test-ob-maxima.el
index 08f7dc04d8..e2433d232a 100644
--- a/testing/lisp/test-ob-maxima.el
+++ b/testing/lisp/test-ob-maxima.el
@@ -1,4 +1,4 @@
-;;; test-ob-maxima.el --- tests for ob-maxima.el
+;;; test-ob-maxima.el --- tests for ob-maxima.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el
index 6113b40f31..78ce102144 100644
--- a/testing/lisp/test-ob-octave.el
+++ b/testing/lisp/test-ob-octave.el
@@ -1,4 +1,4 @@
-;;; test-ob-octave.el --- tests for ob-octave.el
+;;; test-ob-octave.el --- tests for ob-octave.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
 ;; Authors: Sergey Litvinov
diff --git a/testing/lisp/test-ob-perl.el b/testing/lisp/test-ob-perl.el
index 38521dbbad..5826e8cca2 100644
--- a/testing/lisp/test-ob-perl.el
+++ b/testing/lisp/test-ob-perl.el
@@ -1,4 +1,4 @@
-;;; test-ob-perl.el --- tests for ob-perl.el
+;;; test-ob-perl.el --- tests for ob-perl.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2013, 2014, 2019 Achim Gratz
 ;; Authors: Achim Gratz
diff --git a/testing/lisp/test-ob-plantuml.el b/testing/lisp/test-ob-plantuml.el
index bdbd1a74bb..6b0aab9617 100644
--- a/testing/lisp/test-ob-plantuml.el
+++ b/testing/lisp/test-ob-plantuml.el
@@ -1,4 +1,4 @@
-;;; test-ob-plantuml.el --- tests for ob-plantuml.el
+;;; test-ob-plantuml.el --- tests for ob-plantuml.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2016, 2019 Thibault Marin
 ;; Authors: Thibault Marin
diff --git a/testing/lisp/test-ob-python.el b/testing/lisp/test-ob-python.el
index 2032b7e8db..e4442bf9b0 100644
--- a/testing/lisp/test-ob-python.el
+++ b/testing/lisp/test-ob-python.el
@@ -1,4 +1,4 @@
-;;; test-ob-python.el --- tests for ob-python.el
+;;; test-ob-python.el --- tests for ob-python.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-ruby.el b/testing/lisp/test-ob-ruby.el
index 9f224a7653..5e2438c6d4 100644
--- a/testing/lisp/test-ob-ruby.el
+++ b/testing/lisp/test-ob-ruby.el
@@ -1,4 +1,4 @@
-;;; test-ob-ruby.el --- tests for ob-ruby.el
+;;; test-ob-ruby.el --- tests for ob-ruby.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2013-2015, 2019 Oleh Krehel
 ;; Authors: Oleh Krehel
diff --git a/testing/lisp/test-ob-sed.el b/testing/lisp/test-ob-sed.el
index 0c0515ecd4..a91aa54cce 100644
--- a/testing/lisp/test-ob-sed.el
+++ b/testing/lisp/test-ob-sed.el
@@ -1,4 +1,4 @@
-;;; test-ob-sed.el --- tests for ob-sed.el
+;;; test-ob-sed.el --- tests for ob-sed.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2015, 2019 Bjarte Johansen
 ;; Authors: Bjarte Johansen
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index 6f673740bf..7c18e39cee 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -1,4 +1,4 @@
-;;; test-ob-shell.el
+;;; test-ob-shell.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-sql.el b/testing/lisp/test-ob-sql.el
index aacdaa7a30..6590711214 100644
--- a/testing/lisp/test-ob-sql.el
+++ b/testing/lisp/test-ob-sql.el
@@ -1,4 +1,4 @@
-;;; test-ob-sql.el --- tests for ob-sql.el
+;;; test-ob-sql.el --- tests for ob-sql.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2021 Robin Joy
 
diff --git a/testing/lisp/test-ob-sqlite.el b/testing/lisp/test-ob-sqlite.el
index c2dc480c2e..5c418e304f 100644
--- a/testing/lisp/test-ob-sqlite.el
+++ b/testing/lisp/test-ob-sqlite.el
@@ -1,4 +1,4 @@
-;;; test-ob-sqlite.el --- tests for ob-sqlite.el
+;;; test-ob-sqlite.el --- tests for ob-sqlite.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2017, 2019  Eduardo Bellani
 
diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el
index 3f450c2d7f..e83014f2e1 100644
--- a/testing/lisp/test-ob-table.el
+++ b/testing/lisp/test-ob-table.el
@@ -1,4 +1,4 @@
-;;; test-ob-table.el
+;;; test-ob-table.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 618e118e08..555c861e51 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -1,4 +1,4 @@
-;;; test-ob-tangle.el --- tests for ob-tangle.el
+;;; test-ob-tangle.el --- tests for ob-tangle.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2016, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index c944ccd392..c3a0f21bce 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -1,4 +1,4 @@
-;;; test-ob.el --- tests for ob.el
+;;; test-ob.el --- tests for ob.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2015, 2019 Eric Schulte
 ;; Authors: Eric Schulte, Martyn Jago
diff --git a/testing/lisp/test-org-attach-git.el b/testing/lisp/test-org-attach-git.el
index 7fa3a43169..cc2a1dc627 100644
--- a/testing/lisp/test-org-attach-git.el
+++ b/testing/lisp/test-org-attach-git.el
@@ -1,4 +1,4 @@
-;;; test-org-attach-git.el --- Tests for Org Attach with git-annex
+;;; test-org-attach-git.el --- Tests for Org Attach with git-annex  -*- lexical-binding: t; -*-
 ;;
 ;; Copyright (c) 2016, 2019 Erik Hetzner
 ;; Authors: Erik Hetzner
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index c9768eb6b5..04022905c3 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1,4 +1,4 @@
-;;; test-org-clock.el --- Tests for org-clock.el
+;;; test-org-clock.el --- Tests for org-clock.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012, 2014, 2015, 2019  Nicolas Goaziou
 
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 89eb2a3607..bf5e0ffd6e 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1,4 +1,4 @@
-;;; test-org-element.el --- Tests for org-element.el
+;;; test-org-element.el --- Tests for org-element.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2015, 2019  Nicolas Goaziou
 
diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el
index a26346175c..0fa800deef 100644
--- a/testing/lisp/test-org-fold.el
+++ b/testing/lisp/test-org-fold.el
@@ -1,4 +1,4 @@
-;;; test-org.el --- tests for org.el
+;;; test-org.el --- tests for org.el  -*- lexical-binding: t; -*-
 
 ;; Authors: Ihor Radchenko
 
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index 8751dc842b..94c8bc7b20 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -1,4 +1,4 @@
-;;; test-org-footnote.el --- Tests for org-footnote.el
+;;; test-org-footnote.el --- Tests for org-footnote.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2015, 2019  Nicolas Goaziou
 
diff --git a/testing/lisp/test-org-inlinetask.el b/testing/lisp/test-org-inlinetask.el
index db46376790..e31a148a53 100644
--- a/testing/lisp/test-org-inlinetask.el
+++ b/testing/lisp/test-org-inlinetask.el
@@ -1,4 +1,4 @@
-;;; test-org-inlinetask.el --- Tests for org-inlinetask.el
+;;; test-org-inlinetask.el --- Tests for org-inlinetask.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c)  Marco Wahl
 ;; Authors: Marco Wahl
diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el
index ab6bc54523..c253b00a89 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -1,4 +1,4 @@
-;;; test-org-list.el --- Tests for org-list.el
+;;; test-org-list.el --- Tests for org-list.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012, 2013, 2014, 2018, 2019  Nicolas Goaziou
 
diff --git a/testing/lisp/test-org-macro.el b/testing/lisp/test-org-macro.el
index f1bc4f4503..3339945fa1 100644
--- a/testing/lisp/test-org-macro.el
+++ b/testing/lisp/test-org-macro.el
@@ -1,4 +1,4 @@
-;;; test-org-macro.el --- Tests for org-macro.el
+;;; test-org-macro.el --- Tests for org-macro.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2013, 2014, 2019  Nicolas Goaziou
 
diff --git a/testing/lisp/test-org-pcomplete.el b/testing/lisp/test-org-pcomplete.el
index 34969f284d..a9f46dd2f8 100644
--- a/testing/lisp/test-org-pcomplete.el
+++ b/testing/lisp/test-org-pcomplete.el
@@ -1,4 +1,4 @@
-;;; test-org-pcomplete.el --- test pcomplete integration
+;;; test-org-pcomplete.el --- test pcomplete integration  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2015-2016, 2019  Alexey Lebedeff
 ;; Authors: Alexey Lebedeff
diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
index 16283b5977..2a45ba66e5 100644
--- a/testing/lisp/test-org-src.el
+++ b/testing/lisp/test-org-src.el
@@ -1,4 +1,4 @@
-;;; test-org-src.el --- tests for org-src.el
+;;; test-org-src.el --- tests for org-src.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2015, 2019  Le Wang
 
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index 310844c94c..f3fb4d98db 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -1,4 +1,4 @@
-;;; test-org-table.el --- tests for org-table.el
+;;; test-org-table.el --- tests for org-table.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c)  David Maus
 ;; Authors: David Maus, Michael Brand
diff --git a/testing/lisp/test-org-timer.el b/testing/lisp/test-org-timer.el
index 5d938f22ec..930e548a63 100644
--- a/testing/lisp/test-org-timer.el
+++ b/testing/lisp/test-org-timer.el
@@ -1,4 +1,4 @@
-;;; test-org-timer.el --- Tests for org-timer.el
+;;; test-org-timer.el --- Tests for org-timer.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2014-2015, 2019  Kyle Meyer
 
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 004e89732d..5ab97e1a7e 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1,4 +1,4 @@
-;;; test-org.el --- tests for org.el
+;;; test-org.el --- tests for org.el  -*- lexical-binding: t -*-
 
 ;; Copyright (c)  David Maus
 ;; Authors: David Maus
@@ -23,6 +23,7 @@
 ;;; Code:
 
 (eval-and-compile (require 'cl-lib))
+(eval-when-compile (require 'org-macs)) ;For `org-with-gensyms'.
 
 \f
 ;;; Helpers
diff --git a/testing/lisp/test-property-inheritance.el b/testing/lisp/test-property-inheritance.el
index d3c3b0c642..ede25b4901 100644
--- a/testing/lisp/test-property-inheritance.el
+++ b/testing/lisp/test-property-inheritance.el
@@ -1,4 +1,4 @@
-;;; test-property-inheritance.el --- tests for property-inheritance.el
+;;; test-property-inheritance.el --- tests for property-inheritance.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2011-2014, 2019 Eric Schulte
 ;; Authors: Eric Schulte
diff --git a/testing/org-batch-test-init.el b/testing/org-batch-test-init.el
index 87216cffda..4c8cf4e385 100644
--- a/testing/org-batch-test-init.el
+++ b/testing/org-batch-test-init.el
@@ -1,4 +1,4 @@
-;;
+;;  -*- lexical-binding: t; -*-
 ;; Remove Org remnants built into Emacs
 ;;
 
diff --git a/testing/org-test.el b/testing/org-test.el
index 54b21a6598..8f500c5104 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -1,4 +1,4 @@
-;;;; org-test.el --- Tests for Org
+;;;; org-test.el --- Tests for Org  -*- lexical-binding: t; -*-
 
 ;; Copyright (c) 2010-2015 Sebastian Rose, Eric Schulte
 ;; Authors:

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-13  0:05 Use lexical-scoping in tests Stefan Monnier
@ 2022-09-14 12:32 ` Ihor Radchenko
  2022-09-14 18:23   ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-09-14 12:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-orgmode

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> The patch below simply enables `lexical-binding` in all the test files.
> As far as I can tell, it's all that's needed (beside a missing
> `require`).

Thanks, but the patch causes 23 tests to fail (running make test).
Also, is there any reason why it was a plain diff?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-14 12:32 ` Ihor Radchenko
@ 2022-09-14 18:23   ` Stefan Monnier
  2022-09-14 21:34     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2022-09-14 18:23 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko [2022-09-14 20:32:53] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The patch below simply enables `lexical-binding` in all the test files.
>> As far as I can tell, it's all that's needed (beside a missing
>> `require`).
> Thanks, but the patch causes 23 tests to fail (running make test).

Oh, lord!

The fix is in preparation, but obviously I had tested my patch
incorrectly (i.e. I probably compiled and tested another code than the
one I had patched).

[ At least it explains why I was seeing this weird "it's all that's
  needed", which I always hope for but is so rarely true.  ]

> Also, is there any reason why it was a plain diff?

Lack of inspiration, mostly.


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-14 18:23   ` Stefan Monnier
@ 2022-09-14 21:34     ` Stefan Monnier
  2022-09-15 14:22       ` Ihor Radchenko
  2022-09-16  3:38       ` Ihor Radchenko
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2022-09-14 21:34 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

> The fix is in preparation, but obviously I had tested my patch
> incorrectly (i.e. I probably compiled and tested another code than the
> one I had patched).

OK, here's a better version.  As you can see, it's not nearly as simple.


        Stefan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testing-Make-all-files-use-lexical-binding.patch --]
[-- Type: text/x-diff, Size: 81489 bytes --]

From 9cd41bcbb6ca6771bd4c79f8b9d07241c67250ea Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed, 14 Sep 2022 17:21:37 -0400
Subject: [PATCH] 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.
---
 lisp/ob-core.el                             | 57 +++++++---------
 lisp/org-protocol.el                        |  4 +-
 lisp/org.el                                 |  9 ++-
 testing/examples/babel.el                   |  1 +
 testing/lisp/test-ob-C.el                   |  2 +-
 testing/lisp/test-ob-R.el                   |  8 ++-
 testing/lisp/test-ob-awk.el                 |  2 +-
 testing/lisp/test-ob-clojure.el             |  2 +-
 testing/lisp/test-ob-emacs-lisp.el          | 33 +++++----
 testing/lisp/test-ob-eshell.el              |  2 +-
 testing/lisp/test-ob-exp.el                 |  9 ++-
 testing/lisp/test-ob-fortran.el             |  2 +-
 testing/lisp/test-ob-header-arg-defaults.el |  2 +-
 testing/lisp/test-ob-java.el                |  7 +-
 testing/lisp/test-ob-julia.el               |  3 +-
 testing/lisp/test-ob-lilypond.el            |  8 +--
 testing/lisp/test-ob-lob.el                 |  5 +-
 testing/lisp/test-ob-lua.el                 |  2 +-
 testing/lisp/test-ob-maxima.el              |  2 +-
 testing/lisp/test-ob-octave.el              |  2 +-
 testing/lisp/test-ob-perl.el                |  2 +-
 testing/lisp/test-ob-plantuml.el            |  5 +-
 testing/lisp/test-ob-python.el              |  3 +-
 testing/lisp/test-ob-ruby.el                |  2 +-
 testing/lisp/test-ob-sed.el                 |  2 +-
 testing/lisp/test-ob-shell.el               |  3 +-
 testing/lisp/test-ob-sql.el                 |  2 +-
 testing/lisp/test-ob-sqlite.el              |  2 +-
 testing/lisp/test-ob-table.el               |  2 +-
 testing/lisp/test-ob-tangle.el              |  4 +-
 testing/lisp/test-ob.el                     | 18 +++--
 testing/lisp/test-oc.el                     |  4 +-
 testing/lisp/test-ol.el                     |  3 +
 testing/lisp/test-org-agenda.el             |  4 +-
 testing/lisp/test-org-archive.el            |  2 +
 testing/lisp/test-org-attach-git.el         |  2 +-
 testing/lisp/test-org-attach.el             |  7 +-
 testing/lisp/test-org-capture.el            |  2 +-
 testing/lisp/test-org-clock.el              |  5 +-
 testing/lisp/test-org-colview.el            |  5 +-
 testing/lisp/test-org-datetree.el           |  2 +
 testing/lisp/test-org-duration.el           |  2 +
 testing/lisp/test-org-element.el            |  9 +--
 testing/lisp/test-org-fold.el               |  2 +-
 testing/lisp/test-org-footnote.el           |  4 +-
 testing/lisp/test-org-inlinetask.el         |  2 +-
 testing/lisp/test-org-lint.el               |  5 +-
 testing/lisp/test-org-list.el               |  7 +-
 testing/lisp/test-org-macro.el              |  2 +-
 testing/lisp/test-org-pcomplete.el          |  4 +-
 testing/lisp/test-org-protocol.el           |  6 +-
 testing/lisp/test-org-src.el                |  2 +-
 testing/lisp/test-org-table.el              | 10 +--
 testing/lisp/test-org-timer.el              |  5 +-
 testing/lisp/test-org.el                    | 76 +++++++++++----------
 testing/lisp/test-ox-publish.el             | 28 ++++----
 testing/lisp/test-ox.el                     | 45 ++++++------
 testing/lisp/test-property-inheritance.el   |  2 +-
 testing/org-batch-test-init.el              | 16 +++--
 testing/org-test.el                         | 50 +++++++-------
 60 files changed, 290 insertions(+), 230 deletions(-)

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-14 21:34     ` Stefan Monnier
@ 2022-09-15 14:22       ` Ihor Radchenko
  2022-09-15 17:29         ` Stefan Monnier
  2022-09-16  3:38       ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-09-15 14:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-orgmode


Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The fix is in preparation, but obviously I had tested my patch
>> incorrectly (i.e. I probably compiled and tested another code than the
>> one I had patched).
>
> OK, here's a better version.  As you can see, it's not nearly as simple.

Thanks!
This new version passes all the tests on my side.
However, I have a few questions about FIXME items.

> +		;; FIXME: `s' is a symbol, so (car-safe s) is always nil.
> +		;;(when (eq 'autoload (car-safe s))
> +		;;  (unintern s obarray))
> +		))))

If I understand correctly, the intended version of this code is supposed
to be

  (when (autoloadp (symbol-function s))
    (unintern s obarray))

the idea being "unloading" all the built-in org-related staff.
However, make test will be failing then with byte-compiler error.
I feel that the idea of the code is reasonable, but some detail of how
autoloads work in Emacs is missed.
  
> +	   ;; 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))

Could you please elaborate about this fixme?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-15 14:22       ` Ihor Radchenko
@ 2022-09-15 17:29         ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2022-09-15 17:29 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>> +		;; FIXME: `s' is a symbol, so (car-safe s) is always nil.
>> +		;;(when (eq 'autoload (car-safe s))
>> +		;;  (unintern s obarray))
>> +		))))
>
> If I understand correctly, the intended version of this code is supposed
> to be
>
>   (when (autoloadp (symbol-function s))
>     (unintern s obarray))
>
> the idea being "unloading" all the built-in org-related staff.
> However, make test will be failing then with byte-compiler error.
> I feel that the idea of the code is reasonable, but some detail of how
> autoloads work in Emacs is missed.

I don't see why you'd need to remove the existing autoloads: they don't
specify which directory the file will come from, so if the file still
exists in the new Org, the (old) autoload will load from the new Org,
as needed.

I mean it's OK to remove those autoloads, but really, those are usually
harmless and they are the least of your problems.  I think the things
we'd want/need to "remove" are those things which *aren't* autoloads.

Also `unintern` is a fairly powerful operation which can come with
undesirable side-effects, so I'd rather replace it with something less
risky like `fmakunbound`.

>> +	   ;; 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))
>
> Could you please elaborate about this fixme?

`find-file` displays the buffer in a window.  In most uses of this code
we don't care whether the buffer is displayed or not, so we should
probably use `find-file-noselect` instead.
[ As a rule of thumb, most uses of `find-file` (and `switch-to-buffer`)
  in ELisp code are the result of a misunderstanding from the coder who
  just uses the commands he's familiar with as a user.  But in Elisp,
  you generally want to use `find-file-noselect` (and `set-buffer`, or
  maybe `pop-to-buffer`) instead.  ]

I didn't make the change, tho, because some parts of the tests do care
about which buffer is displayed in which window, apparently, so it would
take more work.


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-14 21:34     ` Stefan Monnier
  2022-09-15 14:22       ` Ihor Radchenko
@ 2022-09-16  3:38       ` Ihor Radchenko
  2022-09-16  3:59         ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-09-16  3:38 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-orgmode

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> The fix is in preparation, but obviously I had tested my patch
>> incorrectly (i.e. I probably compiled and tested another code than the
>> one I had patched).
>
> OK, here's a better version.  As you can see, it's not nearly as simple.

Applied onto main + commits addressing all but one FIXME (the one about
`find-file' in org-test.el).
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1a5e3f931c9bbefaefafd4cdcc5f0dfcd1c97769
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=17b51973bd17f26b4dfa0a5d5f198c7e1c8461dd
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6074a22bcb25593bd7644b2695d38f8b41200463
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e3348ccc03b0aa3e8f8b3d0837b91f8285fe161a

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Use lexical-scoping in tests
  2022-09-16  3:38       ` Ihor Radchenko
@ 2022-09-16  3:59         ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2022-09-16  3:59 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>> OK, here's a better version.  As you can see, it's not nearly as simple.
>
> Applied onto main + commits addressing all but one FIXME (the one about
> `find-file' in org-test.el).

Great, thanks,


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-16  4:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-13  0:05 Use lexical-scoping in tests Stefan Monnier
2022-09-14 12:32 ` Ihor Radchenko
2022-09-14 18:23   ` Stefan Monnier
2022-09-14 21:34     ` Stefan Monnier
2022-09-15 14:22       ` Ihor Radchenko
2022-09-15 17:29         ` Stefan Monnier
2022-09-16  3:38       ` Ihor Radchenko
2022-09-16  3:59         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).