emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phpinspect 2d29bce498: Apply overall code quality impro


From: ELPA Syncer
Subject: [elpa] externals/phpinspect 2d29bce498: Apply overall code quality improvements
Date: Wed, 16 Aug 2023 03:58:17 -0400 (EDT)

branch: externals/phpinspect
commit 2d29bce49887e62dd18ca84805aa301cf09fde62
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>

    Apply overall code quality improvements
    
    Even benchmarks and tests now compile without warnings or errors :)
    
    This includes patches from Stefan Monnier:
    - https://lists.gnu.org/archive/html/emacs-devel/2023-08/msg00548.html
---
 benchmarks/parse-file.el        |  38 +++++---
 benchmarks/splay-tree.el        |   8 +-
 compile.bash                    |   5 +-
 phpinspect-index.el             |  23 +++--
 phpinspect-parse-context.el     |   2 +-
 phpinspect-parser.el            | 204 +++++++++++++++++++---------------------
 phpinspect-pipeline.el          |  12 ++-
 phpinspect-splayt.el            |  44 ++++-----
 phpinspect-util.el              |   9 +-
 phpinspect.el                   |  74 +++++++--------
 test/phpinspect-test-env.el     |  12 +--
 test/phpinspect-test.el         |   5 +-
 test/test-autoload.el           |  22 ++---
 test/test-bmap.el               |  10 +-
 test/test-buffer.el             |  18 ++--
 test/test-edtrack.el            |   3 +-
 test/test-index.el              |  16 +++-
 test/test-meta.el               |  25 -----
 test/test-parse-context.el      |   1 +
 test/test-parser.el             |  19 +---
 test/test-pipeline.el           |  20 ++--
 test/test-project.el            |   4 +-
 test/test-resolvecontext.el     |  19 ++--
 test/test-splayt.el             |   6 +-
 test/test-toc.el                |   1 +
 test/test-type.el               |   2 +
 test/test-util.el               |   2 +
 test/util/generate-test-data.el |   6 +-
 28 files changed, 294 insertions(+), 316 deletions(-)

diff --git a/benchmarks/parse-file.el b/benchmarks/parse-file.el
index 89bc6f2cb9..a769770799 100644
--- a/benchmarks/parse-file.el
+++ b/benchmarks/parse-file.el
@@ -30,30 +30,35 @@
    (current-buffer)
    (point-max)))
 
-(let ((here (file-name-directory (or load-file-name buffer-file-name))))
+(let ((here (file-name-directory (macroexp-file-name)))
+      result)
 
   (with-temp-buffer
-    (insert-file-contents (concat here "/Response.php"))
+    (insert-file-contents (expand-file-name "Response.php" here))
 
     (message "Incremental parse (warmup):")
     (phpinspect-with-parse-context (phpinspect-make-pctx :incremental t :bmap 
(phpinspect-make-bmap))
-      (benchmark 1 '(phpinspect-parse-current-buffer)))
+      (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
+
+    (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result))
 
     (let ((bmap (phpinspect-make-bmap))
           (bmap2 (phpinspect-make-bmap)))
       (message "Incremental parse:")
       (phpinspect-with-parse-context (phpinspect-make-pctx :incremental t 
:bmap bmap)
-        (benchmark 1 '(phpinspect-parse-current-buffer)))
+        (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
 
-      (garbage-collect)
+      (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result))
 
+      (garbage-collect)
       (message "Incremental parse (no edits):")
       (phpinspect-with-parse-context (phpinspect-make-pctx :incremental t
                                                            :bmap bmap2
                                                            :previous-bmap bmap
                                                            :edtrack 
(phpinspect-make-edtrack))
-        (benchmark 1 '(phpinspect-parse-current-buffer)))
+        (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
 
+      (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result))
       (garbage-collect)
 
       (message "Incremental parse repeat (no edits):")
@@ -61,7 +66,8 @@
                                                            :bmap 
(phpinspect-make-bmap)
                                                            :previous-bmap bmap2
                                                            :edtrack 
(phpinspect-make-edtrack))
-        (benchmark 1 '(phpinspect-parse-current-buffer)))
+        (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
+      (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result))
 
       (garbage-collect)
 
@@ -81,8 +87,9 @@
 
         (phpinspect-edtrack-register-edit edtrack 9061 9061 1)
         (phpinspect-with-parse-context (phpinspect-make-pctx :bmap bmap-after 
:incremental t :previous-bmap bmap :edtrack edtrack)
-          (benchmark 1 '(phpinspect-parse-current-buffer)))
+          (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
 
+        (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr 
result) (cadr result))
         (phpinspect-edtrack-clear edtrack)
         (insert "{")
 
@@ -98,22 +105,27 @@
                                                              :incremental t
                                                              :previous-bmap 
bmap-after
                                                              :edtrack edtrack)
-          (benchmark 1 '(phpinspect-parse-current-buffer)))
+          (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
+
+        (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr 
result) (cadr result))
 
         ;; (save-current-buffer
         ;;   (profiler-stop)
         ;;   (profiler-report)
-        ;;   (profiler-report-write-profile (concat here "/profile.txt")))
+        ;;   (profiler-report-write-profile (expand-file-name "profile.txt" 
here)))
         )))
 
   (with-temp-buffer
-    (insert-file-contents (concat here "/Response.php"))
+    (insert-file-contents (expand-file-name "Response.php" here))
 
     (garbage-collect)
     (message "Bare (no token reuse) parse (warmup):")
-    (benchmark 1 '(phpinspect-parse-current-buffer))
+    (setq result (benchmark-run 1 (phpinspect-parse-current-buffer)))
 
+    (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result))
 
     (garbage-collect)
     (message "Bare (no token reuse) parse:")
-    (benchmark 1 '(phpinspect-parse-current-buffer))))
+    (setq result (benchmark-run 1 (phpinspect-parse-current-buffer))))
+
+  (message "Elapsed time: %f (%f in %d GC's)" (car result) (caddr result) 
(cadr result)))
diff --git a/benchmarks/splay-tree.el b/benchmarks/splay-tree.el
index 99ff38cec3..ef350f8267 100644
--- a/benchmarks/splay-tree.el
+++ b/benchmarks/splay-tree.el
@@ -53,7 +53,7 @@
   (setq result
         (benchmark-run 1
           (phpinspect-splayt-traverse (i tree)
-            i)))
+            (ignore i))))
 
   (message "Elapsed time: %f (%f in %d GC's)"
            (car result) (caddr result) (cadr result))
@@ -64,7 +64,7 @@
   (setq result
         (benchmark-run 1
           (phpinspect-splayt-traverse-lr (i tree)
-            i)))
+            (ignore i))))
   (message "Elapsed time: %f (%f in %d GC's)"
            (car result) (caddr result) (cadr result)))
 
@@ -87,7 +87,7 @@
   (setq result
         (benchmark-run 1
           (dotimes (i 10000)
-            (gethash i map))))
+            (ignore (gethash i map)))))
 
   (message "Elapsed time: %f (%f in %d GC's)"
            (car result) (caddr result) (cadr result))
@@ -97,7 +97,7 @@
   (garbage-collect)
   (setq result
         (benchmark-run 1
-          (maphash (lambda (k v) k v) map)))
+          (ignore (maphash (lambda (k v) k v) map))))
 
   (message "Elapsed time: %f (%f in %d GC's)"
            (car result) (caddr result) (cadr result)))
diff --git a/compile.bash b/compile.bash
index e5cecf7e17..5353dbabc7 100644
--- a/compile.bash
+++ b/compile.bash
@@ -1,11 +1,14 @@
 #!/bin/bash
 
+rm ./**/*.elc
+rm *.elc
+
 for file in ./*.el; do
     cask emacs -batch -L . --eval '(setq byte-compile-error-on-warn t)' -f 
batch-byte-compile "$file" || break
 done
 
 for file in ./**/*.el; do
-    cask emacs -batch -L . --eval '(setq byte-compile-error-on-warn nil)' -f 
batch-byte-compile "$file" || break
+    cask emacs -batch -L . --eval '(setq byte-compile-error-on-warn t)' -f 
batch-byte-compile "$file" || break
 done
 
 if [[ -z $NO_REMOVE_ELC ]]; then
diff --git a/phpinspect-index.el b/phpinspect-index.el
index 7f442fa622..b3dc9d1bcf 100644
--- a/phpinspect-index.el
+++ b/phpinspect-index.el
@@ -405,8 +405,9 @@ NAMESPACE will be assumed the root namespace if not 
provided"
   "Find usage of the \"new\" keyword in TOKENS.
 
 Return value is a list of the types that are \"newed\"."
-  (let ((previous-tokens)
-        (used-types))
+  (let* ((previous-tokens)
+         (used-types (cons nil nil))
+         (used-types-rear used-types))
     (while tokens
       (let ((token (pop tokens))
             (previous-token (car previous-tokens)))
@@ -415,23 +416,25 @@ Return value is a list of the types that are \"newed\"."
                     (phpinspect-word-p token))
                (let ((type (cadr token)))
                  (when (not (string-match-p "\\\\" type))
-                   (push type used-types))))
+                   (setq used-types-rear (setcdr used-types-rear (cons type 
nil))))))
               ((and (phpinspect-static-attrib-p token)
                     (phpinspect-word-p previous-token))
                (let ((type (cadr previous-token)))
                  (when (not (string-match-p "\\\\" type))
-                   (push type used-types))))
+                   (setq used-types-rear (setcdr used-types-rear (cons type 
nil))))))
               ((phpinspect-object-attrib-p token)
                (let ((lists (seq-filter #'phpinspect-list-p token)))
                  (dolist (list lists)
-                   (setq used-types (append 
(phpinspect--find-used-types-in-tokens (cdr list))
-                                            used-types)))))
+                   (setq used-types-rear
+                         (nconc used-types-rear
+                                (phpinspect--find-used-types-in-tokens (cdr 
list)))
+                         used-types-rear (last used-types-rear)))))
               ((or (phpinspect-list-p token) (phpinspect-block-p token))
-               (setq used-types (append (phpinspect--find-used-types-in-tokens 
(cdr token))
-                                        used-types))))
-
+               (setq used-types-rear
+                     (nconc used-types-rear 
(phpinspect--find-used-types-in-tokens (cdr token)))
+                     used-types-rear (last used-types-rear))))
         (push token previous-tokens)))
-    used-types))
+    (cdr used-types)))
 
 (defun phpinspect--index-tokens (tokens &optional type-resolver-factory 
location-resolver)
   "Index TOKENS as returned by `phpinspect--parse-current-buffer`."
diff --git a/phpinspect-parse-context.el b/phpinspect-parse-context.el
index f5c6401e1f..e56e5d1687 100644
--- a/phpinspect-parse-context.el
+++ b/phpinspect-parse-context.el
@@ -36,7 +36,7 @@ parsing. Usually used in combination with
   "Parser Context"
   (incremental nil)
   (meta-iterator nil)
-  (interrupt-threshold (time-convert '(0 0 2000 0))
+  (interrupt-threshold (time-convert '(0 0 2000 0) t)
                        :documentation
                        "After how much time `interrupt-predicate'
 should be polled. This is 2ms by default.")
diff --git a/phpinspect-parser.el b/phpinspect-parser.el
index ccef0e2f04..67bd327053 100644
--- a/phpinspect-parser.el
+++ b/phpinspect-parser.el
@@ -144,116 +144,110 @@ HANDLERS must be a list of symbols referring to existing
 parser handlers defined using `phpinspect-defhandler'.
 
 DELIMITER-PREDICATE must be a function.  It is passed the last
-parsed token after every handler iteration.  If it evaluates to
+parsed token after every handler iteration.  If it returns
 something other than nil, parsing is deemed completed and the
 loop exits.  An example use case of this is to determine the end
 of a statement.  You can use `phpinspect-terminator-p` as
 delimiter predicate and have parsing stop when the last parsed
 token is \";\", which marks the end of a statement in PHP."
-    (let ((delimiter-predicate (if (symbolp delimiter-predicate)
-                                   `(quote ,delimiter-predicate)
-                                 delimiter-predicate)))
-      `(defsubst ,(phpinspect-parser-func-name name "simple") (buffer 
max-point &optional skip-over continue-condition &rest _ignored)
-         (with-current-buffer buffer
-           (let* ((tokens (cons ,tree-type nil))
-                  (tokens-rear tokens)
-                  token
-                  (delimiter-predicate (when (functionp ,delimiter-predicate) 
,delimiter-predicate)))
-             (when skip-over (forward-char skip-over))
+    (cl-assert (symbolp delimiter-predicate))
+    `(defun ,(phpinspect-parser-func-name name "simple") (buffer max-point 
&optional skip-over continue-condition &rest _ignored)
+       (with-current-buffer buffer
+         (let* ((tokens (cons ,tree-type nil))
+                (tokens-rear tokens)
+                token)
+           (when skip-over (forward-char skip-over))
+           (while (and (< (point) max-point)
+                       (if continue-condition (funcall continue-condition) t)
+                       (not ,(if delimiter-predicate
+                                   `(,delimiter-predicate (car (last tokens)))
+                                 nil)))
+             (cond ,@(mapcar
+                      (lambda (handler)
+                        `((looking-at (,(phpinspect-handler-regexp-func-name 
handler)))
+                          (setq token (,(phpinspect-handler-func-name handler) 
(match-string 0) max-point))
+                          (when token
+                            (setq tokens-rear (setcdr tokens-rear (cons token 
nil))))))
+                      handlers)
+                   (t (forward-char))))
+
+           ;; Return
+           tokens))))
+
+
+  (defun phpinspect-make-incremental-parser-function (name tree-type handlers 
&optional delimiter-predicate)
+    "Like `phpinspect-make-parser-function', but returned function
+is able to reuse an already parsed tree."
+    (cl-assert (symbolp delimiter-predicate))
+    `(defun ,(phpinspect-parser-func-name name "incremental") (context buffer 
max-point &optional skip-over continue-condition root)
+       (with-current-buffer buffer
+         (let* ((tokens (cons ,tree-type nil))
+                (tokens-rear tokens)
+                (root-start (point))
+                (bmap (phpinspect-pctx-bmap context))
+                (previous-bmap (phpinspect-pctx-previous-bmap context))
+                (edtrack (phpinspect-pctx-edtrack context))
+                (taint-iterator (when edtrack 
(phpinspect-edtrack-make-taint-iterator edtrack)))
+                (check-interrupt (phpinspect-pctx-interrupt-predicate context))
+
+                ;; Loop variables
+                (start-position)
+                (original-position)
+                (current-end-position)
+                (existing-meta)
+                (delta)
+                (token))
+           (when skip-over (forward-char skip-over))
+           (phpinspect-pctx-save-whitespace context
              (while (and (< (point) max-point)
                          (if continue-condition (funcall continue-condition) t)
-                         (not (if delimiter-predicate
-                                  (funcall delimiter-predicate (car (last 
tokens)))
-                                nil)))
-               (cond ,@(mapcar
+                         (not ,(if delimiter-predicate
+                                   `(,delimiter-predicate (car (last tokens)))
+                                 nil)))
+               (when check-interrupt
+                 (phpinspect-pctx-check-interrupt context))
+
+               (setq start-position (point))
+               (cond ((and previous-bmap edtrack
+                           (setq existing-meta
+                                 (phpinspect-bmap-token-starting-at
+                                  previous-bmap
+                                  (setq original-position
+                                        
(phpinspect-edtrack-original-position-at-point edtrack start-position))))
+                           (not (or (phpinspect-root-p (phpinspect-meta-token 
existing-meta))
+                                    
(phpinspect-taint-iterator-token-is-tainted-p taint-iterator existing-meta))))
+                      (setq delta (- start-position original-position)
+                            current-end-position (+ (phpinspect-meta-end 
existing-meta) delta)
+                            token (phpinspect-meta-token existing-meta))
+
+                      ;;(message "Reusing token  %s at point %s" 
(phpinspect-meta-string existing-meta) (point))
+                      ;; Re-register existing token
+                      (phpinspect-bmap-overlay
+                       bmap previous-bmap existing-meta delta
+                       (phpinspect-pctx-consume-whitespace context))
+
+                      (goto-char current-end-position)
+
+                      ;; Skip over whitespace after so that we don't do a full
+                      ;; run down all of the handlers during the next iteration
+                      (when (looking-at (phpinspect-handler-regexp whitespace))
+                        (,(phpinspect-handler-func-name 'whitespace) 
(match-string 0))))
+                     ,@(mapcar
                         (lambda (handler)
                           `((looking-at (,(phpinspect-handler-regexp-func-name 
handler)))
                             (setq token (,(phpinspect-handler-func-name 
handler) (match-string 0) max-point))
                             (when token
-                              (setq tokens-rear (setcdr tokens-rear (cons 
token nil))))))
+                              (phpinspect-pctx-register-token context token 
start-position (point)))))
                         handlers)
-                     (t (forward-char))))
-
-             ;; Return
-             tokens)))))
+                     (t (forward-char)))
+               (when token
+                 (setq tokens-rear (setcdr tokens-rear (cons token nil)))
+                 (setq token nil))))
+           (when root
+             (phpinspect-pctx-register-token context tokens root-start 
(point)))
 
-
-  (defun phpinspect-make-incremental-parser-function (name tree-type handlers 
&optional delimiter-predicate)
-    "Like `phpinspect-make-parser-function', but returned function
-is able to reuse an already parsed tree."
-    (let ((delimiter-predicate (if (symbolp delimiter-predicate)
-                                   `(quote ,delimiter-predicate)
-                                 delimiter-predicate)))
-      `(defsubst ,(phpinspect-parser-func-name name "incremental") (context 
buffer max-point &optional skip-over continue-condition root)
-         (with-current-buffer buffer
-           (let* ((tokens (cons ,tree-type nil))
-                  (tokens-rear tokens)
-                  (root-start (point))
-                  (bmap (phpinspect-pctx-bmap context))
-                  (previous-bmap (phpinspect-pctx-previous-bmap context))
-                  (edtrack (phpinspect-pctx-edtrack context))
-                  (taint-iterator (when edtrack 
(phpinspect-edtrack-make-taint-iterator edtrack)))
-                  (check-interrupt (phpinspect-pctx-interrupt-predicate 
context))
-
-                  ;; Loop variables
-                  (start-position)
-                  (original-position)
-                  (current-end-position)
-                  (existing-meta)
-                  (delta)
-                  (token)
-                  (delimiter-predicate (when (functionp ,delimiter-predicate) 
,delimiter-predicate)))
-             (when skip-over (forward-char skip-over))
-             (phpinspect-pctx-save-whitespace context
-               (while (and (< (point) max-point)
-                           (if continue-condition (funcall continue-condition) 
t)
-                           (not (if delimiter-predicate
-                                    (funcall delimiter-predicate (car (last 
tokens)))
-                                  nil)))
-                 (when check-interrupt
-                   (phpinspect-pctx-check-interrupt context))
-
-                 (setq start-position (point))
-                 (cond ((and previous-bmap edtrack
-                             (setq existing-meta
-                                   (phpinspect-bmap-token-starting-at
-                                    previous-bmap
-                                    (setq original-position
-                                          
(phpinspect-edtrack-original-position-at-point edtrack start-position))))
-                             (not (or (phpinspect-root-p 
(phpinspect-meta-token existing-meta))
-                                      
(phpinspect-taint-iterator-token-is-tainted-p taint-iterator existing-meta))))
-                        (setq delta (- start-position original-position)
-                              current-end-position (+ (phpinspect-meta-end 
existing-meta) delta)
-                              token (phpinspect-meta-token existing-meta))
-
-                        ;;(message "Reusing token  %s at point %s" 
(phpinspect-meta-string existing-meta) (point))
-                        ;; Re-register existing token
-                        (phpinspect-bmap-overlay
-                         bmap previous-bmap existing-meta delta
-                         (phpinspect-pctx-consume-whitespace context))
-
-                        (goto-char current-end-position)
-
-                        ;; Skip over whitespace after so that we don't do a 
full
-                        ;; run down all of the handlers during the next 
iteration
-                        (when (looking-at (phpinspect-handler-regexp 
whitespace))
-                          (,(phpinspect-handler-func-name 'whitespace) 
(match-string 0))))
-                       ,@(mapcar
-                          (lambda (handler)
-                            `((looking-at 
(,(phpinspect-handler-regexp-func-name handler)))
-                              (setq token (,(phpinspect-handler-func-name 
handler) (match-string 0) max-point))
-                              (when token
-                                (phpinspect-pctx-register-token context token 
start-position (point)))))
-                          handlers)
-                       (t (forward-char)))
-                 (when token
-                   (setq tokens-rear (setcdr tokens-rear (cons token nil)))
-                   (setq token nil))))
-             (when root
-               (phpinspect-pctx-register-token context tokens root-start 
(point)))
-
-             ;; Return
-             tokens)))))
+           ;; Return
+           tokens))))
 
   (cl-defstruct (phpinspect-parser (:constructor phpinspect-make-parser))
     (name 'root
@@ -475,21 +469,21 @@ nature like argument lists"
         (cond ((string= annotation-name "var")
                ;; The @var annotation accepts 2 parameters:
                ;; the type and the $variable name
-               (append (list :var-annotation)
-                       (phpinspect--parse-annotation-parameters 2)))
+               (cons :var-annotation
+                     (phpinspect--parse-annotation-parameters 2)))
               ((string= annotation-name "return")
                ;; The @return annotation only accepts 1 word as parameter:
                ;; The return type
-               (append (list :return-annotation)
-                       (phpinspect--parse-annotation-parameters 1)))
+               (cons :return-annotation
+                     (phpinspect--parse-annotation-parameters 1)))
               ((string= annotation-name "param")
                  ;; The @param annotation accepts 2 parameters:
                  ;; The type of the param, and the param's $name
-                 (append (list :param-annotation)
-                         (phpinspect--parse-annotation-parameters 2)))
+                 (cons :param-annotation
+                       (phpinspect--parse-annotation-parameters 2)))
               ((string= annotation-name "method")
-               (append (list :method-annotation)
-                       (phpinspect--parse-annotation-parameters 3)))
+               (cons :method-annotation
+                     (phpinspect--parse-annotation-parameters 3)))
               (t
                (list :annotation annotation-name))))
     (list :annotation nil)))
diff --git a/phpinspect-pipeline.el b/phpinspect-pipeline.el
index c9c7cf2085..83236284ef 100644
--- a/phpinspect-pipeline.el
+++ b/phpinspect-pipeline.el
@@ -258,9 +258,10 @@ directories."
 
       (pcase key
         (:into
-         (let ((parameters)
-               (name)
-               (construct-params))
+         (let* ((construct-params (cons nil nil))
+                (cons-params-rear construct-params)
+                parameters name)
+
            (if (listp value)
                (progn
                  (setq name (car value)
@@ -275,8 +276,9 @@ directories."
                (setq key (pop parameters)
                      value (pop parameters))
                (setq key (intern (string-replace ":with-" ":" (symbol-name 
key))))
-               (setq construct-params (nconc construct-params (list key 
value)))))
-           (push (apply #'phpinspect--make-pipeline-step `(,@construct-params 
:name ,name))
+               (setq cons-params-rear
+                     (setcdr cons-params-rear (cons key (cons value nil))))))
+           (push (apply #'phpinspect--make-pipeline-step `(,@(cdr 
construct-params) :name ,name))
                  steps)))
         (_ (error "unexpected key %s" key))))
 
diff --git a/phpinspect-splayt.el b/phpinspect-splayt.el
index 339bf3739a..ba59fcb1d9 100644
--- a/phpinspect-splayt.el
+++ b/phpinspect-splayt.el
@@ -279,23 +279,20 @@ apeared to be a little more performant than using `let'."
        nil)))
 
 (defmacro phpinspect-splayt-traverse (place-and-splayt &rest body)
-  "Traverse splay tree in cadr of PLACE-AND-SPLAYT, executing BODY.
+  "Traverse SPLAYT, executing BODY.
 
-The car of PLACE-AND-SPLAYT is assigned the value of each node.
+The PLACE is assigned the value of each node.
 
-Traversal is breadth-first to take advantage of the splay trees
+Traversal is breadth-first to take advantage of the splay trees'
 main benefit: the most accessed interval of keys is likely to be
-near the top of the tee."
+near the top of the tee.
+
+(fn (PLACE SPLAYT) BODY...)"
   (declare (indent 1))
- (let* ((current (gensym))
-         (code `(phpinspect-splayt-node-traverse
-                    (,current (phpinspect-splayt-root-node ,(cadr 
place-and-splayt)))
-                  (setf ,(car place-and-splayt) (phpinspect-splayt-node-value 
,current))
-                  ,@body)))
-    (if (symbolp (car place-and-splayt))
-        `(let (,(car place-and-splayt))
-           ,code)
-      code)))
+  `(phpinspect-splayt-node-traverse
+       (,(car place-and-splayt) (phpinspect-splayt-root-node ,(cadr 
place-and-splayt)))
+     (setf ,(car place-and-splayt) (phpinspect-splayt-node-value ,(car 
place-and-splayt)))
+     ,@body))
 
 (defmacro phpinspect-splayt-node-traverse-lr (place-and-node &rest body)
   (declare (indent 1))
@@ -316,21 +313,16 @@ near the top of the tee."
            (setq ,current (phpinspect-splayt-node-right ,current)))))))
 
 (defmacro phpinspect-splayt-traverse-lr (place-and-splayt &rest body)
-  "Traverse splay tree depth-first from left to right,executing BODY.
+  "Traverse SPLAYT depth-first from left to right,executing BODY.
 
-The car of PLACE-AND-SPLAYT is assigned the value of each node.
-The cadr of PLACE-AND-SPLAYT is expected to be a splay tree."
-  (declare (indent 1))
-  (let* ((current (gensym))
-         (code `(phpinspect-splayt-node-traverse-lr
-                    (,current (phpinspect-splayt-root-node ,(cadr 
place-and-splayt)))
-                  (setf ,(car place-and-splayt) (phpinspect-splayt-node-value 
,current))
-                  ,@body)))
-    (if (symbolp (car place-and-splayt))
-        `(let (,(car place-and-splayt))
-           ,code)
-      code)))
+The PLACE is assigned the value of each node.
 
+(fn (PLACE SPLAYT) BODY...)"
+  (declare (indent 1))
+  `(phpinspect-splayt-node-traverse-lr
+       (,(car place-and-splayt) (phpinspect-splayt-root-node ,(cadr 
place-and-splayt)))
+     (setf ,(car place-and-splayt) (phpinspect-splayt-node-value ,(car 
place-and-splayt)))
+     ,@body))
 
 (define-inline phpinspect-splayt-node-key-less-p (node key)
   (inline-quote (> ,key (phpinspect-splayt-node-key ,node))))
diff --git a/phpinspect-util.el b/phpinspect-util.el
index 3c04f7f7fb..05c1f11dcc 100644
--- a/phpinspect-util.el
+++ b/phpinspect-util.el
@@ -51,7 +51,8 @@ PHP. Used to optimize string comparison.")
 
   (inline-quote
    (progn
-     (add-to-list 'phpinspect-log-groups (cons (or load-file-name 
buffer-file-name) ,group) nil #'equal))))
+     (add-to-list 'phpinspect-log-groups
+                  (cons (macroexp-file-name) ,group)))))
 
 (defun phpinspect-log-group-enabled-p (group)
   (seq-find (lambda (cons)
@@ -61,7 +62,8 @@ PHP. Used to optimize string comparison.")
 (phpinspect--declare-log-group 'bam)
 
 (defmacro phpinspect--log (&rest args)
-  (let ((log-group (alist-get (or load-file-name buffer-file-name) 
phpinspect-log-groups nil nil #'string=)))
+  (let ((log-group (alist-get (macroexp-file-name)
+                              phpinspect-log-groups nil nil #'string=)))
     `(when (and phpinspect--debug
                 (or (not phpinspect-enabled-log-groups)
                     ,(when log-group
@@ -77,7 +79,8 @@ PHP. Used to optimize string comparison.")
 (defun phpinspect-filter-logs (group-name)
   (interactive (list (completing-read "Log group: "
                                       (mapcar (lambda (g) (symbol-name (cdr 
g)))
-                                              phpinspect-log-groups) nil t)))
+                                              phpinspect-log-groups)
+                                      nil t)))
   (add-to-list 'phpinspect-enabled-log-groups (intern group-name)))
 
 (defun phpinspect-unfilter-logs ()
diff --git a/phpinspect.el b/phpinspect.el
index 6785f63e38..411b892cc3 100644
--- a/phpinspect.el
+++ b/phpinspect.el
@@ -173,57 +173,57 @@ Example configuration if you already have a completion
 UI (Company, Corfu) setup that can take advantage of completion
 at point (capf) functions:
 
-(defun my-php-personal-hook ()
-  ;; Shortcut to add use statements for classes you use.
-  (define-key php-mode-map (kbd \"C-c u\") #\\='phpinspect-fix-imports)
+    (defun my-php-personal-hook ()
+      ;; Shortcut to add use statements for classes you use.
+      (define-key php-mode-map (kbd \"C-c u\") #\\='phpinspect-fix-imports)
 
-  ;; Shortcuts to quickly search/open files of PHP classes.
-  ;; You can make these local to php-mode, but making them global
-  ;; like this makes them work in other modes/filetypes as well, which
-  ;; can be handy when jumping between templates, config files and PHP code.
-  (global-set-key (kbd \"C-c a\") #\\='phpinspect-find-class-file)
-  (global-set-key (kbd \"C-c c\") #\\='phpinspect-find-own-class-file)
+      ;; Shortcuts to quickly search/open files of PHP classes.
+      ;; You can make these local to php-mode, but making them global
+      ;; like this makes them work in other modes/filetypes as well, which
+      ;; can be handy when jumping between templates, config files and PHP 
code.
+      (global-set-key (kbd \"C-c a\") #\\='phpinspect-find-class-file)
+      (global-set-key (kbd \"C-c c\") #\\='phpinspect-find-own-class-file)
 
-  ;; Enable phpinspect-mode
-  (phpinspect-mode))
+      ;; Enable phpinspect-mode
+      (phpinspect-mode))
 
-(add-hook 'php-mode-hook #'my-php-personal-hook)
+    (add-hook \\='php-mode-hook #\\='my-php-personal-hook)
 
 
 Example configuration for `company-mode':
 
-  (defun my-php-personal-hook ()
-    ;; Assuming you already have company-mode enabled, these settings
-    ;; add some IDE-like flair to it. This is of course not required, do
-    ;; with it what you like.
-    (setq-local company-minimum-prefix-length 0)
-    (setq-local company-tooltip-align-annotations t)
-    (setq-local company-idle-delay 0.1)
+    (defun my-php-personal-hook ()
+      ;; Assuming you already have company-mode enabled, these settings
+      ;; add some IDE-like flair to it. This is of course not required, do
+      ;; with it what you like.
+      (setq-local company-minimum-prefix-length 0)
+      (setq-local company-tooltip-align-annotations t)
+      (setq-local company-idle-delay 0.1)
 
-    ;; If you don't have company-mode enabled by default, uncomment this line:
-    ;; (company-mode)
+      ;; If you don't have company-mode enabled by default, uncomment this 
line:
+      ;; (company-mode)
 
-    ;; By default, phpinspect-mode adds itself as a backend to
-    ;; the `company-backends' of the current buffer. You can completely
-    ;; disable all other backends with the statement below.
-    (setq-local company-backends '(phpinspect-company-backend))
+      ;; By default, phpinspect-mode adds itself as a backend to
+      ;; the `company-backends' of the current buffer. You can completely
+      ;; disable all other backends with the statement below.
+      (setq-local company-backends \\='(phpinspect-company-backend))
 
-    ;; Shortcut to add use statements for classes you use.
-    (define-key php-mode-map (kbd \"C-c u\") 'phpinspect-fix-imports)
+      ;; Shortcut to add use statements for classes you use.
+      (define-key php-mode-map (kbd \"C-c u\") #\\='phpinspect-fix-imports)
 
-    ;; Shortcuts to quickly search/open files of PHP classes.
-    ;; You can make these local to php-mode, but making them global
-    ;; like this makes them work in other modes/filetypes as well, which
-    ;; can be handy when jumping between templates, config files and PHP code.
-    (global-set-key (kbd \"C-c a\") 'phpinspect-find-class-file)
-    (global-set-key (kbd \"C-c c\") 'phpinspect-find-own-class-file)
+      ;; Shortcuts to quickly search/open files of PHP classes.
+      ;; You can make these local to php-mode, but making them global
+      ;; like this makes them work in other modes/filetypes as well, which
+      ;; can be handy when jumping between templates, config files and PHP 
code.
+      (global-set-key (kbd \"C-c a\") #\\='phpinspect-find-class-file)
+      (global-set-key (kbd \"C-c c\") #\\='phpinspect-find-own-class-file)
 
-    ;; Enable phpinspect-mode
-    (phpinspect-mode))
+      ;; Enable phpinspect-mode
+      (phpinspect-mode))
 
-  (add-hook 'php-mode-hook #'my-php-personal-hook)
+    (add-hook \\='php-mode-hook #\\='my-php-personal-hook)
 
-;; End example configuration."
+    ;; End example configuration."
   :after-hook (phpinspect--mode-function))
 
 (defun phpinspect--suggest-at-point ()
diff --git a/test/phpinspect-test-env.el b/test/phpinspect-test-env.el
index 5f8d2e574f..8325721af8 100644
--- a/test/phpinspect-test-env.el
+++ b/test/phpinspect-test-env.el
@@ -11,18 +11,12 @@
 (phpinspect-purge-cache)
 
 (defvar phpinspect-test-directory
-  (file-name-directory
-   (or load-file-name
-       buffer-file-name))
+  (file-name-directory (macroexp-file-name))
   "Directory that phpinspect tests reside in.")
 
 
 (defvar phpinspect-test-php-file-directory
-  (concat
-   (file-name-directory
-    (or load-file-name
-        buffer-file-name))
-   "/fixtures")
+  (expand-file-name "fixtures" phpinspect-test-directory)
   "Directory with syntax trees of example PHP files.")
 
 (defun phpinspect-test-read-fixture-data (name)
@@ -33,7 +27,7 @@
 (defun phpinspect-test-read-fixture-serialization (name)
   (with-temp-buffer
     (insert-file-contents-literally (concat phpinspect-test-php-file-directory 
"/" name ".eld"))
-    (eval (read (current-buffer)))))
+    (eval (read (current-buffer)) t)))
 
 (defun phpinspect-test-parse-fixture-code (name)
   (phpinspect-parse-file
diff --git a/test/phpinspect-test.el b/test/phpinspect-test.el
index 234701356b..409fdcc5fb 100644
--- a/test/phpinspect-test.el
+++ b/test/phpinspect-test.el
@@ -27,8 +27,8 @@
 (require 'phpinspect)
 
 (require 'phpinspect-test-env
-         (concat (file-name-directory (or load-file-name buffer-file-name 
byte-compile-current-file))
-                 "phpinspect-test-env.el"))
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
 
 (ert-deftest phpinspect-get-variable-type-in-block ()
   (let* ((code "class Foo { function a(\\Thing $baz) { $foo = new 
\\DateTime(); $bar = $foo; Whatever comes after don't matter.")
@@ -514,6 +514,7 @@ class Thing
 (load-file (concat phpinspect-test-directory "/test-splayt.el"))
 (load-file (concat phpinspect-test-directory "/test-pipeline.el"))
 (load-file (concat phpinspect-test-directory "/test-toc.el"))
+(load-file (concat phpinspect-test-directory "/test-meta.el"))
 
 
 (provide 'phpinspect-test)
diff --git a/test/test-autoload.el b/test/test-autoload.el
index 7f51a22020..c9737a52a3 100644
--- a/test/test-autoload.el
+++ b/test/test-autoload.el
@@ -27,6 +27,7 @@
 (require 'ert)
 (require 'phpinspect-fs)
 (require 'phpinspect-autoload)
+(require 'phpinspect-resolvecontext)
 
 (ert-deftest phpinspect-filename-to-typename ()
   (should (eq (phpinspect-intern-name "\\Foo\\Bar") 
(phpinspect-filename-to-typename "src/" "src/Foo////////Bar.php")))
@@ -35,13 +36,7 @@
 
 
 (ert-deftest phpinspect-find-composer-json-files ()
-  (let* ((fs (phpinspect-make-virtual-fs))
-         (autoloader (phpinspect-make-autoloader
-                      :fs fs
-                      :project-root-resolver (lambda () "/root")
-                      :file-indexer
-                      (phpinspect-project-make-file-indexer
-                       (phpinspect--make-project :root "/root" :fs fs)))))
+  (let* ((fs (phpinspect-make-virtual-fs)))
     (phpinspect-virtual-fs-set-file fs
       "/root/composer.json"
       "{ \"autoload\": { \"psr-4\": {\"WoW\\\\Dwarves\\\\\": \"src/\"}}}")
@@ -57,12 +52,13 @@
 
     (let ((sorter (lambda (file1 file2) (string-lessp (cdr file1) (cdr 
file2)))))
 
-    (should (equal (sort '((vendor . "/root/vendor/apples/pears/composer.json")
-                           (vendor . 
"/root/vendor/runescape/client/composer.json")
-                           (local . "/root/composer.json"))
-                         sorter)
-                   (sort (phpinspect-find-composer-json-files fs "/root")
-                         sorter))))))
+      (should (equal (sort (copy-sequence
+                            '((vendor . 
"/root/vendor/apples/pears/composer.json")
+                              (vendor . 
"/root/vendor/runescape/client/composer.json")
+                              (local . "/root/composer.json")))
+                           sorter)
+                     (sort (phpinspect-find-composer-json-files fs "/root")
+                           sorter))))))
 
 (ert-deftest phpinspect-autoload-composer-json-iterator ()
   (let* ((fs (phpinspect-make-virtual-fs))
diff --git a/test/test-bmap.el b/test/test-bmap.el
index 613efaecfd..e0c17c7f52 100644
--- a/test/test-bmap.el
+++ b/test/test-bmap.el
@@ -1,3 +1,4 @@
+;; -*- lexical-binding: t; -*-
 
 (require 'phpinspect-bmap)
 
@@ -6,7 +7,6 @@
         (bmap2 (phpinspect-make-bmap))
         (bmap3 (phpinspect-make-bmap))
         (token '(:token))
-        (token1 '(:token1))
         (token2 '(:token2))
         (token3 '(:token3)))
 
@@ -69,13 +69,15 @@
     (phpinspect-bmap-register bmap 9  20 '(:node3))
     (phpinspect-bmap-register bmap 21  44 '(:node4))
 
-    (setq result (phpinspect-bmap-tokens-overlapping bmap 22))
-    (should (equal '((:node4) (:node2) (:node1)) (mapcar 
#'phpinspect-meta-token result)))))
+    (let ((result (phpinspect-bmap-tokens-overlapping bmap 22)))
+      (should (equal '((:node4) (:node2) (:node1))
+                     (mapcar #'phpinspect-meta-token result))))))
 
 (ert-deftest phpinspect-bmap-tokens-overlapping-overlayed ()
   (let ((bmap (phpinspect-make-bmap))
         (bmap2 (phpinspect-make-bmap))
-        (bmap3 (phpinspect-make-bmap)))
+        (bmap3 (phpinspect-make-bmap))
+        result)
     (phpinspect-bmap-register bmap 9 200 '(:token1))
     (phpinspect-bmap-register bmap 20 200 '(:token2))
     (phpinspect-bmap-register bmap 9 20 '(:token3))
diff --git a/test/test-buffer.el b/test/test-buffer.el
index a697bdd6c1..c8872870b8 100644
--- a/test/test-buffer.el
+++ b/test/test-buffer.el
@@ -27,12 +27,11 @@
 (require 'phpinspect-parser)
 (require 'phpinspect-buffer)
 (require 'phpinspect-test-env
-         (concat (file-name-directory (or load-file-name buffer-file-name 
byte-compile-current-file))
-                 "phpinspect-test-env.el"))
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
 
 (ert-deftest phpinspect-buffer-region-lookups ()
-  (let* ((parsed)
-         (class))
+  (let* (parsed)
     (with-temp-buffer
       (insert-file-contents (concat phpinspect-test-php-file-directory 
"/NamespacedClass.php"))
       (setq phpinspect-current-buffer
@@ -54,12 +53,11 @@
 (ert-deftest phpinspect-parse-buffer-no-current ()
   "Confirm that the parser is still functional with
 `phpinspect-current-buffer' unset."
-  (let*((buffer)
-        (parsed))
-    (with-temp-buffer
-      (should-not phpinspect-current-buffer)
-      (insert-file-contents (concat phpinspect-test-php-file-directory 
"/NamespacedClass.php"))
-      (setq parsed (phpinspect-parse-current-buffer)))
+  (let* ((parsed
+          (with-temp-buffer
+            (should-not phpinspect-current-buffer)
+            (insert-file-contents (expand-file-name "NamespacedClass.php" 
phpinspect-test-php-file-directory))
+            (phpinspect-parse-current-buffer))))
 
     (should (cdr parsed))))
 
diff --git a/test/test-edtrack.el b/test/test-edtrack.el
index b12ddc8360..adc2391578 100644
--- a/test/test-edtrack.el
+++ b/test/test-edtrack.el
@@ -106,8 +106,7 @@
     (should-not (phpinspect-taint-iterator-region-is-tainted-p iterator 30 
35))))
 
 (ert-deftest phpinspect-edtrack-taint-overlapping-edits ()
-  (let ((track (phpinspect-make-edtrack))
-        iterator)
+  (let ((track (phpinspect-make-edtrack)))
     (phpinspect-edtrack-register-edit track 10 20 5)
 
     (should (equal (list (cons 10 15)) (phpinspect-edtrack-taint-pool track)))
diff --git a/test/test-index.el b/test/test-index.el
index 232cc1c9ae..f5c092f847 100644
--- a/test/test-index.el
+++ b/test/test-index.el
@@ -24,6 +24,13 @@
 ;;; Code:
 (require 'ert)
 (require 'phpinspect-index)
+(require 'phpinspect-parse-context)
+(require 'phpinspect-bmap)
+(require 'phpinspect-parser)
+(require 'phpinspect-test-env
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
+
 
 (ert-deftest phpinspect-index-static-methods ()
   (let* ((class-tokens
@@ -92,8 +99,9 @@ return StaticThing::create(new 
ThingFactory())->makeThing((((new Potato())->anti
     (should (equal
              (mapcar #'phpinspect-intern-name
                      (sort
-                      '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" "ExtendedThing"
-                        "StaticThing" "Thing" "ThingFactory" "Potato" 
"OtherThing")
+                      (copy-sequence
+                       '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" 
"ExtendedThing"
+                         "StaticThing" "Thing" "ThingFactory" "Potato" 
"OtherThing"))
                       #'string<))
              (sort used-types (lambda (s1 s2) (string< (symbol-name s1) 
(symbol-name s2))))))))
 
@@ -111,7 +119,7 @@ return StaticThing::create(new 
ThingFactory())->makeThing((((new Potato())->anti
                    ("Request" "Response")))))
     (dolist (set blocks)
       (let ((result (phpinspect--find-used-types-in-tokens (car set))))
-        (should (equal (cadr set) result))))))
+        (should (equal (sort (copy-sequence (cadr set)) #'string-lessp) (sort 
result #'string-lessp)))))))
 
 (ert-deftest phpinspect-index-method-annotations ()
   (let* ((result (phpinspect--index-tokens
@@ -172,7 +180,7 @@ return StaticThing::create(new 
ThingFactory())->makeThing((((new Potato())->anti
   (let* ((pctx (phpinspect-make-pctx :incremental t :bmap 
(phpinspect-make-bmap)))
          (tree))
     (with-temp-buffer
-      (insert-file-contents (concat phpinspect-test-php-file-directory 
"/IndexClass1.php"))
+      (insert-file-contents (expand-file-name "IndexClass1.php" 
phpinspect-test-php-file-directory))
       (setf (phpinspect-pctx-bmap pctx) (phpinspect-make-bmap))
       (phpinspect-with-parse-context pctx (setq tree 
(phpinspect-parse-current-buffer))))
     (let* ((index1 (phpinspect--index-tokens tree
diff --git a/test/test-meta.el b/test/test-meta.el
index df85c81b9e..6f997622f1 100644
--- a/test/test-meta.el
+++ b/test/test-meta.el
@@ -40,28 +40,3 @@
     (should (= 30 (phpinspect-meta-start meta)))
 
     (should (phpinspect-meta-overlaps-point meta 30))))
-
-(ert-deftest phpinspect-meta-iterator ()
-  (let* ((meta (phpinspect-make-meta nil 10 20 "" 'token))
-         (firstchild (phpinspect-make-meta nil 10 12 "" 'token))
-         (secondchild (phpinspect-make-meta nil 13 15 "" 'token))
-         (parent1 (phpinspect-make-meta nil 9 22 "" 'token))
-         (sibling (phpinspect-make-meta nil 30 55 "" 'token))
-         (parent2 (phpinspect-make-meta nil 0 100 "" 'token))
-         iterator)
-    (phpinspect-meta-set-parent meta parent1)
-    (phpinspect-meta-set-parent parent1 parent2)
-    (phpinspect-meta-set-parent sibling parent2)
-    (phpinspect-meta-set-parent firstchild meta)
-    (phpinspect-meta-set-parent secondchild meta)
-
-    (setq iterator (phpinspect-make-meta-iterator parent2))
-
-    (should (eq meta (phpinspect-meta-iterator-token-at-point iterator 10)))
-    (should (eq sibling (phpinspect-meta-iterator-token-at-point iterator 30)))
-    (should (eq meta (phpinspect-meta-iterator-token-at-point iterator 10)))
-    (should (eq firstchild (phpinspect-meta-iterator-token-at-point iterator 
10)))
-    (should (eq secondchild (phpinspect-meta-iterator-token-at-point iterator 
13)))
-    (should (eq meta (phpinspect-meta-iterator-token-at-point iterator 10)))
-    (should (eq firstchild (phpinspect-meta-iterator-token-at-point iterator 
10)))
-    (should (eq sibling (phpinspect-meta-iterator-token-at-point iterator 
30)))))
diff --git a/test/test-parse-context.el b/test/test-parse-context.el
index a9d69c2384..4fffdc4e61 100644
--- a/test/test-parse-context.el
+++ b/test/test-parse-context.el
@@ -26,6 +26,7 @@
 (require 'ert)
 (require 'phpinspect-parse-context)
 (require 'phpinspect-meta)
+(require 'phpinspect-bmap)
 
 (ert-deftest phpinspect-pctx-cancel ()
   (let ((meta (phpinspect-make-meta nil 10 20 "    " 'token 'overlay nil))
diff --git a/test/test-parser.el b/test/test-parser.el
index a7b3660d67..0e86853e83 100644
--- a/test/test-parser.el
+++ b/test/test-parser.el
@@ -24,21 +24,10 @@
 ;;; Code:
 
 (require 'phpinspect-parser)
-
-(defvar phpinspect-test-directory
-  (file-name-directory
-   (or load-file-name
-       buffer-file-name))
-  "Directory that phpinspect tests reside in.")
-
-
-(defvar phpinspect-test-php-file-directory
-  (concat
-   (file-name-directory
-    (or load-file-name
-        buffer-file-name))
-   "/fixtures")
-  "Directory with syntax trees of example PHP files.")
+(require 'phpinspect-index)
+(require 'phpinspect-test-env
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
 
 
 (ert-deftest phpinspect-parse-bmap ()
diff --git a/test/test-pipeline.el b/test/test-pipeline.el
index f9c1ed04a3..27e3334723 100644
--- a/test/test-pipeline.el
+++ b/test/test-pipeline.el
@@ -25,14 +25,15 @@
 
 (require 'phpinspect-pipeline)
 
+(defun phpinspect--correct-the-record (input)
+  (phpinspect-pipeline-emit
+   (format "It's not %s, but GNU/%s" input input)))
+
 (ert-deftest phpinspect-pipeline ()
-  (let (result error thread)
-    (defun correct-the-record (input)
-      (phpinspect-pipeline-emit
-       (format "It's not %s, but GNU/%s" input input)))
+  (let (result error)
 
     (phpinspect-pipeline (list "Linux" "Emacs")
-      :into correct-the-record
+      :into phpinspect--correct-the-record
       :async (lambda (res err)
                (setq result res
                      error err)))
@@ -44,13 +45,14 @@
                    result))
     (should-not error)))
 
+(defun phpinspect--aah-it-broke (input)
+  (signal 'it-brokey input))
+
 (ert-deftest phpinspect-pipeline-error ()
-  (defun aah-it-broke (input)
-    (signal 'it-brokey input))
 
   (let (result error)
     (phpinspect-pipeline (list "Holy smokey")
-      :into aah-it-broke
+      :into phpinspect--aah-it-broke
       :async (lambda (res err)
                (setq result res
                      error err)))
@@ -60,5 +62,5 @@
 
     (should error)
     (should (equal '(phpinspect-pipeline-error
-                     "Thread phpinspect-pipeline-aah-it-broke signaled error: 
(it-brokey . Holy smokey)")
+                     "Thread phpinspect-pipeline-phpinspect--aah-it-broke 
signaled error: (it-brokey . Holy smokey)")
                    error))))
diff --git a/test/test-project.el b/test/test-project.el
index b421eebc7c..719ad15774 100644
--- a/test/test-project.el
+++ b/test/test-project.el
@@ -35,11 +35,9 @@
 (ert-deftest phpinspect-project-watch-file-and-purge ()
   (let* ((root (make-temp-file "phpinspect-test" 'dir))
          (fs (phpinspect-make-fs))
-         (worker (phpinspect-make-worker))
          (watch-file (concat root "/watch1"))
          (project (phpinspect--make-project :fs fs :root root)))
-    (phpinspect-project-watch-file project watch-file
-                                    (lambda (&rest ignored)))
+    (phpinspect-project-watch-file project watch-file #'ignore)
 
     (phpinspect-project-purge project)
 
diff --git a/test/test-resolvecontext.el b/test/test-resolvecontext.el
index 894f684080..06a27eff8e 100644
--- a/test/test-resolvecontext.el
+++ b/test/test-resolvecontext.el
@@ -1,5 +1,11 @@
+;; -*- lexical-binding: t; -*-
 
 (require 'phpinspect-resolvecontext)
+(require 'phpinspect)
+(require 'phpinspect-test-env
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
+
 
 (ert-deftest phinspect-get-resolvecontext ()
   (let* ((ctx (phpinspect-make-pctx :incremental t :bmap 
(phpinspect-make-bmap)))
@@ -29,7 +35,7 @@ class TestClass {
 
 (ert-deftest phpinspect-type-resolver-for-resolvecontext ()
   (with-temp-buffer
-    (insert-file-contents (concat phpinspect-test-php-file-directory 
"/IncompleteClass.php"))
+    (insert-file-contents (expand-file-name "IncompleteClass.php" 
phpinspect-test-php-file-directory))
     (let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string)))
            (resolvecontext (phpinspect-get-resolvecontext bmap (point-max)))
            (type-resolver (phpinspect--make-type-resolver-for-resolvecontext
@@ -80,10 +86,7 @@ class TestClass {
                                  (funcall type-resolver (phpinspect--make-type 
:name "Dupuis\\GastonLagaffe")))))))
 
 (ert-deftest 
phpinspect-type-resolver-for-resolvecontext-multiple-namespace-blocks ()
-  (with-temp-buffer
-    (insert-file-contents (concat phpinspect-test-php-file-directory 
"/IncompleteClassMultipleNamespaces.php"))
-    (let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string)))
-           (resolvecontext (phpinspect--get-resolvecontext
+  (let* ((resolvecontext (phpinspect--get-resolvecontext
                           (phpinspect-test-read-fixture-data
                            "IncompleteClassMultipleNamespaces")))
          (type-resolver (phpinspect--make-type-resolver-for-resolvecontext
@@ -97,13 +100,13 @@ class TestClass {
                                         (phpinspect--make-type :name 
"\\array"))))
     (should (phpinspect--type= (phpinspect--make-type
                                 :name  
"\\Symfony\\Component\\HttpFoundation\\Response")
-                     (funcall type-resolver (phpinspect--make-type :name 
"Response"))))
+                               (funcall type-resolver (phpinspect--make-type 
:name "Response"))))
     (should (phpinspect--type= (phpinspect--make-type :name  "\\Response")
                                (funcall type-resolver
                                         (phpinspect--make-type :name 
"\\Response"))))
     (should (phpinspect--type= (phpinspect--make-type :name  
"\\App\\Controller\\GastonLagaffe")
-                     (funcall type-resolver (phpinspect--make-type :name 
"GastonLagaffe"))))
+                               (funcall type-resolver (phpinspect--make-type 
:name "GastonLagaffe"))))
     (should (phpinspect--type= (phpinspect--make-type
                                 :name  
"\\App\\Controller\\Dupuis\\GastonLagaffe")
                                (funcall type-resolver (phpinspect--make-type
-                                                       :name 
"Dupuis\\GastonLagaffe")))))))
+                                                       :name 
"Dupuis\\GastonLagaffe"))))))
diff --git a/test/test-splayt.el b/test/test-splayt.el
index 07f37c6e96..04db40f6fa 100644
--- a/test/test-splayt.el
+++ b/test/test-splayt.el
@@ -71,7 +71,7 @@
     (should (string= "twelve" (phpinspect-splayt-find tree 12)))
     (should (string= "eleven" (phpinspect-splayt-find tree 11)))
 
-    (let ((expected (sort '("nine" "three" "eleven" "eight" "twelve" "four" 
"one") #'string-lessp))
+    (let ((expected (sort (copy-sequence '("nine" "three" "eleven" "eight" 
"twelve" "four" "one")) #'string-lessp))
           (result))
 
       (phpinspect-splayt-traverse (item tree)
@@ -91,7 +91,7 @@
     (phpinspect-splayt-insert tree 4 "four")
     (phpinspect-splayt-insert tree 1 "one")
 
-    (let ((expected (sort '("nine" "three" "eleven" "eight" "twelve" "four" 
"one") #'string-lessp))
+    (let ((expected (sort (copy-sequence '("nine" "three" "eleven" "eight" 
"twelve" "four" "one")) #'string-lessp))
           (result))
 
       (phpinspect-splayt-traverse (item tree)
@@ -161,7 +161,7 @@
     (phpinspect-splayt-insert tree 1 "one")
 
 
-    (should (equal (sort '("eight" "nine" "eleven" "twelve") #'string-lessp)
+    (should (equal (sort (copy-sequence '("eight" "nine" "eleven" "twelve")) 
#'string-lessp)
                    (sort (phpinspect-splayt-find-all-after tree 7) 
#'string-lessp)))))
 
 (ert-deftest phpinspect-splayt-to-list ()
diff --git a/test/test-toc.el b/test/test-toc.el
index 99d758290b..4843da3b99 100644
--- a/test/test-toc.el
+++ b/test/test-toc.el
@@ -2,6 +2,7 @@
 
 (require 'phpinspect-toc)
 (require 'phpinspect-splayt)
+(require 'phpinspect-meta)
 
 (ert-deftest phpinspect-make-toc ()
   (let ((tokens (phpinspect-make-splayt))
diff --git a/test/test-type.el b/test/test-type.el
index 47b212e544..d5933cb93a 100644
--- a/test/test-type.el
+++ b/test/test-type.el
@@ -23,6 +23,8 @@
 
 ;;; Code:
 
+(require 'phpinspect-type)
+
 (ert-deftest phpinspect--resolve-late-static-binding ()
   (let* ((sets '(("\\bool" . "\\bool")
                  ("\\static" . "\\AType")
diff --git a/test/test-util.el b/test/test-util.el
index c10e7bd360..72ce39f966 100644
--- a/test/test-util.el
+++ b/test/test-util.el
@@ -23,6 +23,8 @@
 
 ;;; Code:
 
+(require 'phpinspect-util)
+
 (ert-deftest phpinspect--pattern ()
   (let* ((a "a")
          (pattern1 (phpinspect--make-pattern :m `(,a) :m * :m "b"))
diff --git a/test/util/generate-test-data.el b/test/util/generate-test-data.el
index 2211fcac97..a181080ecc 100644
--- a/test/util/generate-test-data.el
+++ b/test/util/generate-test-data.el
@@ -3,12 +3,10 @@
 (require 'phpinspect-index)
 (require 'phpinspect-serialize)
 
-(let ((here (file-name-directory
-             (or load-file-name
-                 buffer-file-name)))
+(let ((here (file-name-directory (macroexp-file-name)))
       (print-length 1000)
       (print-level 1000))
-  (dolist (file (directory-files (concat here "/../fixtures" ) t "\\.php\\'"))
+  (dolist (file (directory-files (expand-file-name "../fixtures" here) t 
"\\.php\\'"))
     (with-temp-buffer
       (insert-file-contents-literally file)
       (let ((result (phpinspect-parse-current-buffer)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]