From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] New Package: phpinspect.el Date: Tue, 15 Aug 2023 18:03:53 -0400 Message-ID: References: <25249bd1-bd1b-5888-b67f-718ffd0ad6ff@hugot.nl> <6c692fd7-24ba-be42-7c73-0cc950561479@hugot.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5520"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Hugo Thunnissen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 16 00:04:49 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qW29g-00019R-US for ged-emacs-devel@m.gmane-mx.org; Wed, 16 Aug 2023 00:04:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW294-0001Lt-Jw; Tue, 15 Aug 2023 18:04:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qW293-0001Le-0B for emacs-devel@gnu.org; Tue, 15 Aug 2023 18:04:09 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qW28x-000411-Li for emacs-devel@gnu.org; Tue, 15 Aug 2023 18:04:08 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BDD90445162; Tue, 15 Aug 2023 18:04:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1692137034; bh=DOOM4tGw3l5way+M7tHx1WkmQMUgM5mdbtSnL9U92L8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YWcVVh4xXsxcaJiUg8q8bKIDoNG5VKh1mZvkjA3+sdBO+B1QKNHmRybFd0vSfFyY/ ya7qXlCOPGFkLbmNosoy+7JHR/doTINExEpQC58c8P+BwWDs3SoF1VjxyscMkw8ZQO eZ2u95scf/uFB9SubuiGslTUios2Q52lqDrmpLkGjcj8pfnYBROoA9zfRSILM5qKF1 MndQN18Ps/U1+w9H7wIvfYHy/VTFnieGJch+j8XrL+rBnkP+Q2A7u0L1zw4futmLm+ HwfJP4xzO6BlbxYZ4rciGVjKyBLgh65sNjZvneiYe/Eh3dMrG1LqkHxpxRbAe5+eyq LtFwz5NXhs4zg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EDD0F445164; Tue, 15 Aug 2023 18:03:53 -0400 (EDT) Original-Received: from pastel (unknown [45.72.228.154]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B8AF3120296; Tue, 15 Aug 2023 18:03:53 -0400 (EDT) In-Reply-To: <6c692fd7-24ba-be42-7c73-0cc950561479@hugot.nl> (Hugo Thunnissen's message of "Tue, 15 Aug 2023 19:45:38 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308779 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable > And here I was thinking that I had fixed all of the byte compilation > problems.. Turns out it was only working because I byte compiled everyth= ing > within the same Emacs session. :-) > I made some changes and think things should > be in order now. At least, the following shell script doesn't seem to > result in any errors: > > for file in ./*.el; do > =A0=A0=A0 cask emacs -batch -L . --eval '(setq byte-compile-error-on-warn= t)' -f > batch-byte-compile "$file" || break > done Yay! And you even saved kittens along the way!!! > I see some warnings in your log that concern files in the "benchmark" and > "test" directories. These files are not required for the package to > function. Can these be excluded from the ELPA build somehow? The log was for a compilation from the Git, not from the ELPA tarball, but you can indeed exclude them from the ELPA tarball by listing those elements in the `.elpaignore` file at the root of your package. You can check the result at http://elpa.gnu.org/devel/phpinspect.html (once it builds a tarball successfully). > I have seen some projects use a "lisp" directory for their source > code, is that the recommended approach for this? No, it's unrelated. BTW, here's another set of patches in you're interested. Stefan --=-=-= Content-Type: text/x-diff; charset=iso-8859-1 Content-Disposition: inline; filename=phpinspect.patch Content-Transfer-Encoding: quoted-printable diff --git a/benchmarks/appendage.el b/benchmarks/appendage.el index 3cb48477b0..6c8a06f880 100644 --- a/benchmarks/appendage.el +++ b/benchmarks/appendage.el @@ -25,29 +25,29 @@ =20 (message "20000 appendages using nconc") (garbage-collect) -(benchmark - 1 '(let (list) - (dotimes (i 20000) - (setq list (nconc list (list i)))) +(benchmark-run 1 + (let (list) + (dotimes (i 20000) + (setq list (nconc list (list i)))) =20 - list)) + list)) =20 (message "20000 appendages using push + nreverse") (garbage-collect) -(benchmark - 1 '(let (list) - (dotimes (i 20000) - (push i list)) +(benchmark-run 1 + (let (list) + (dotimes (i 20000) + (push i list)) =20 - (nreverse list))) + (nreverse list))) =20 (message "20000 appendages using rear pointer") (garbage-collect) -(benchmark - 1 '(let* ((list (cons nil nil)) - (rear list)) +(benchmark-run 1 + (let* ((list (cons nil nil)) + (rear list)) =20 - (dotimes (i 20000) - (setq rear (setcdr rear (cons i nil)))) + (dotimes (i 20000) + (setq rear (setcdr rear (cons i nil)))) =20 - (cdr list))) + (cdr list))) diff --git a/benchmarks/parse-file.el b/benchmarks/parse-file.el index e135ce21c0..1416eedbb8 100644 --- a/benchmarks/parse-file.el +++ b/benchmarks/parse-file.el @@ -30,20 +30,20 @@ (current-buffer) (point-max))) =20 -(let ((here (file-name-directory (or load-file-name buffer-file-name)))) +(let ((here (file-name-directory (macroexp-file-name)))) =20 (with-temp-buffer - (insert-file-contents (concat here "/Response.php")) + (insert-file-contents (expand-file-name "Response.php" here)) =20 (message "Incremental parse (warmup):") (phpinspect-with-parse-context (phpinspect-make-pctx :incremental t :b= map (phpinspect-make-bmap)) - (benchmark 1 '(phpinspect-parse-current-buffer))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 (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))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 (garbage-collect) =20 @@ -52,7 +52,7 @@ :bmap bmap2 :previous-bmap = bmap :edtrack (phpin= spect-make-edtrack)) - (benchmark 1 '(phpinspect-parse-current-buffer))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 (garbage-collect) =20 @@ -61,7 +61,7 @@ :bmap (phpinspe= ct-make-bmap) :previous-bmap = bmap2 :edtrack (phpin= spect-make-edtrack)) - (benchmark 1 '(phpinspect-parse-current-buffer))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 (garbage-collect) =20 @@ -75,13 +75,13 @@ (message "Incremental parse after buffer edit:") ;; Removes closing curly brace of __construct (goto-char 9062) - (delete-backward-char 1) + (delete-char -1) =20 (garbage-collect) =20 (phpinspect-edtrack-register-edit edtrack 9061 9061 1) (phpinspect-with-parse-context (phpinspect-make-pctx :bmap bmap-af= ter :incremental t :previous-bmap bmap :edtrack edtrack) - (benchmark 1 '(phpinspect-parse-current-buffer))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 (phpinspect-edtrack-clear edtrack) (insert "{") @@ -98,22 +98,22 @@ :incremental t :previous-bma= p bmap-after :edtrack edtr= ack) - (benchmark 1 '(phpinspect-parse-current-buffer))) + (benchmark-run 1 (phpinspect-parse-current-buffer))) =20 ;; (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))) ))) =20 (with-temp-buffer - (insert-file-contents (concat here "/Response.php")) + (insert-file-contents (expand-file-name "Response.php" here)) =20 (garbage-collect) (message "Bare (no token reuse) parse (warmup):") - (benchmark 1 '(phpinspect-parse-current-buffer)) + (benchmark-run 1 (phpinspect-parse-current-buffer)) =20 =20 (garbage-collect) (message "Bare (no token reuse) parse:") - (benchmark 1 '(phpinspect-parse-current-buffer)))) + (benchmark-run 1 (phpinspect-parse-current-buffer)))) diff --git a/benchmarks/splay-tree.el b/benchmarks/splay-tree.el index ffd8978f5e..9fc4d9eb38 100644 --- a/benchmarks/splay-tree.el +++ b/benchmarks/splay-tree.el @@ -25,49 +25,49 @@ =20 (require 'phpinspect-splayt) =20 -(let ((here (file-name-directory (or load-file-name buffer-file-name))) +(let ((here (file-name-directory (macroexp-file-name))) (tree (phpinspect-make-splayt))) (message "Splay tree 10000 insertions:") (garbage-collect) - (benchmark - 1 '(dotimes (i 10000) - (phpinspect-splayt-insert tree i 'value))) + (benchmark-run 1 + (dotimes (i 10000) + (phpinspect-splayt-insert tree i 'value))) =20 (message "Splay tree 10000 lookups:") (garbage-collect) - (benchmark - 1 '(dotimes (i 10000) - (phpinspect-splayt-find tree i))) + (benchmark-run 1 + (dotimes (i 10000) + (phpinspect-splayt-find tree i))) =20 (message "Splay tree 10000 items traversal:") (garbage-collect) - (benchmark - 1 '(phpinspect-splayt-traverse (i tree) - nil)) + (benchmark-run 1 + (phpinspect-splayt-traverse (i tree) + nil)) =20 (message "Splay tree 10000 items LR traversal:") (garbage-collect) - (benchmark - 1 '(phpinspect-splayt-traverse-lr (i tree) - nil))) + (benchmark-run 1 + (phpinspect-splayt-traverse-lr (i tree) + nil))) =20 =20 (let (map) (message "Hashtable 10000 insertions:") (garbage-collect) - (benchmark - 1 '(progn - (setq map (make-hash-table :test #'eq :size 10000 :rehash-size 1.5= )) - (dotimes (i 10000) - (puthash i 'value map)))) + (benchmark-run + 1 (progn + (setq map (make-hash-table :test #'eq :size 10000 :rehash-size 1.5)) + (dotimes (i 10000) + (puthash i 'value map)))) =20 (message "Hashtable 10000 lookups:") (garbage-collect) - (benchmark - 1 '(dotimes (i 10000) - (gethash i map))) + (benchmark-run 1 + (dotimes (i 10000) + (gethash i map))) =20 (message "Hashtable 10000 iterations:") (garbage-collect) - (benchmark - 1 '(maphash (lambda (k v) nil) map))) + (benchmark-run 1 + (maphash (lambda (_k _v) nil) map))) 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..211dae59a0 100644 --- a/phpinspect-parser.el +++ b/phpinspect-parser.el @@ -144,116 +144,116 @@ HANDLERS must be a list of symbols referring to exi= sting parser handlers defined using `phpinspect-defhandler'. =20 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-predica= te) ,delimiter-predicate))) - (when skip-over (forward-char skip-over)) + (cl-assert (symbolp delimiter-predicate)) + ;; FIXME: Why `defsubst'? Since there's a loop in this function, + ;; it seems unlikely that the function call overhead will make + ;; any measurable performance difference. + `(defsubst ,(phpinspect-parser-func-name name "simple") (buffer max-po= int &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 token= s))) + nil))) + (cond ,@(mapcar + (lambda (handler) + `((looking-at (,(phpinspect-handler-regexp-func-na= me handler))) + (setq token (,(phpinspect-handler-func-name hand= ler) (match-string 0) max-point)) + (when token + (setq tokens-rear (setcdr tokens-rear (cons to= ken nil)))))) + handlers) + (t (forward-char)))) + + ;; Return + tokens)))) + + + (defun phpinspect-make-incremental-parser-function (name tree-type handl= ers &optional delimiter-predicate) + "Like `phpinspect-make-parser-function', but returned function +is able to reuse an already parsed tree." + (cl-assert (symbolp delimiter-predicate)) + ;; FIXME: Why `defsubst'? Since there's a loop in this function, + ;; it seems unlikely that the function call overhead will make + ;; any measurable performance difference. + `(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-tai= nt-iterator edtrack))) + (check-interrupt (phpinspect-pctx-interrupt-predicate cont= ext)) + + ;; 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-conditio= n) t) - (not (if delimiter-predicate - (funcall delimiter-predicate (car (last = tokens))) - nil))) - (cond ,@(mapcar + (not ,(if delimiter-predicate + `(,delimiter-predicate (car (last token= s))) + 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-posit= ion-at-point edtrack start-position)))) + (not (or (phpinspect-root-p (phpinspect-meta-to= ken existing-meta)) + (phpinspect-taint-iterator-token-is-ta= inted-p taint-iterator existing-meta)))) + (setq delta (- start-position original-position) + current-end-position (+ (phpinspect-meta-end e= xisting-meta) delta) + token (phpinspect-meta-token existing-meta)) + + ;;(message "Reusing token %s at point %s" (phpinspe= ct-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 iter= ation + (when (looking-at (phpinspect-handler-regexp whitesp= ace)) + (,(phpinspect-handler-func-name 'whitespace) (matc= h-string 0)))) + ,@(mapcar (lambda (handler) `((looking-at (,(phpinspect-handler-regexp-func-= name handler))) (setq token (,(phpinspect-handler-func-name ha= ndler) (match-string 0) max-point)) (when token - (setq tokens-rear (setcdr tokens-rear (cons = token nil)))))) + (phpinspect-pctx-register-token context toke= n start-position (point))))) handlers) - (t (forward-char)))) - - ;; Return - tokens))))) - - - (defun phpinspect-make-incremental-parser-function (name tree-type handl= ers &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") (contex= t 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-t= aint-iterator edtrack))) - (check-interrupt (phpinspect-pctx-interrupt-predicate co= ntext)) - - ;; Loop variables - (start-position) - (original-position) - (current-end-position) - (existing-meta) - (delta) - (token) - (delimiter-predicate (when (functionp ,delimiter-predica= te) ,delimiter-predicate))) - (when skip-over (forward-char skip-over)) - (phpinspect-pctx-save-whitespace context - (while (and (< (point) max-point) - (if continue-condition (funcall continue-condit= ion) t) - (not (if delimiter-predicate - (funcall delimiter-predicate (car (las= t 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-pos= ition-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" (phpins= pect-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 it= eration - (when (looking-at (phpinspect-handler-regexp white= space)) - (,(phpinspect-handler-func-name 'whitespace) (ma= tch-string 0)))) - ,@(mapcar - (lambda (handler) - `((looking-at (,(phpinspect-handler-regexp-fun= c-name handler))) - (setq token (,(phpinspect-handler-func-name = handler) (match-string 0) max-point)) - (when token - (phpinspect-pctx-register-token context to= ken 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))))) + (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 (po= int))) + + ;; Return + tokens)))) =20 (cl-defstruct (phpinspect-parser (:constructor phpinspect-make-parser)) (name 'root diff --git a/phpinspect-pipeline.el b/phpinspect-pipeline.el index c9c7cf2085..4e45150807 100644 --- a/phpinspect-pipeline.el +++ b/phpinspect-pipeline.el @@ -275,6 +275,7 @@ directories." (setq key (pop parameters) value (pop parameters)) (setq key (intern (string-replace ":with-" ":" (symbol-name= key)))) + ;; FIXME: There's an O(N=B2) complexity here :-( (setq construct-params (nconc construct-params (list key va= lue))))) (push (apply #'phpinspect--make-pipeline-step `(,@construct-par= ams :name ,name)) steps))) diff --git a/phpinspect-splayt.el b/phpinspect-splayt.el index 339bf3739a..15eac4e6f4 100644 --- a/phpinspect-splayt.el +++ b/phpinspect-splayt.el @@ -279,13 +279,15 @@ apeared to be a little more performant than using `le= t'." nil))) =20 (defmacro phpinspect-splayt-traverse (place-and-splayt &rest body) - "Traverse splay tree in cadr of PLACE-AND-SPLAYT, executing BODY. + "Traverse SPLAYT, executing BODY. =20 -The car of PLACE-AND-SPLAYT is assigned the value of each node. +The PLACE is assigned the value of each node. =20 -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 @@ -293,8 +295,15 @@ near the top of the tee." (setf ,(car place-and-splayt) (phpinspect-splayt-node-va= lue ,current)) ,@body))) (if (symbolp (car place-and-splayt)) + ;; FIXME: You first use `let' to "declare" the var and then + ;; initialize it inside `code'. This is marginally inefficient, + ;; but more importantly it means that if the var is not used in + ;; the rest of `code' the compiler will either complain that the v= ar + ;; is not used or (if it starts with an underscore) complain that + ;; it's used! `(let (,(car place-and-splayt)) ,code) + ;; FIXME: This branch is never used! code))) =20 (defmacro phpinspect-splayt-node-traverse-lr (place-and-node &rest body) 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.") =20 (inline-quote (progn - (add-to-list 'phpinspect-log-groups (cons (or load-file-name buffer-f= ile-name) ,group) nil #'equal)))) + (add-to-list 'phpinspect-log-groups + (cons (macroexp-file-name) ,group))))) =20 (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) =20 (defmacro phpinspect--log (&rest args) - (let ((log-group (alist-get (or load-file-name buffer-file-name) phpinsp= ect-log-groups nil nil #'string=3D))) + (let ((log-group (alist-get (macroexp-file-name) + phpinspect-log-groups nil nil #'string=3D))) `(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 (cd= r g))) - phpinspect-log-groups) nil t= ))) + phpinspect-log-groups) + nil t))) (add-to-list 'phpinspect-enabled-log-groups (intern group-name))) =20 (defun phpinspect-unfilter-logs () diff --git a/phpinspect.el b/phpinspect.el index 6785f63e38..280193423e 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: =20 -(defun my-php-personal-hook () - ;; Shortcut to add use statements for classes you use. - (define-key php-mode-map (kbd \"C-c u\") #\\=3D'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 cod= e. - (global-set-key (kbd \"C-c a\") #\\=3D'phpinspect-find-class-file) - (global-set-key (kbd \"C-c c\") #\\=3D'phpinspect-find-own-class-file) - - ;; Enable phpinspect-mode - (phpinspect-mode)) - -(add-hook 'php-mode-hook #'my-php-personal-hook) + (defun my-php-personal-hook () + ;; Shortcut to add use statements for classes you use. + (define-key php-mode-map (kbd \"C-c u\") #\\=3D'phpinspect-fix-impor= ts) +=20=20=20=20 + ;; 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\") #\\=3D'phpinspect-find-class-file) + (global-set-key (kbd \"C-c c\") #\\=3D'phpinspect-find-own-class-fil= e) +=20=20=20=20 + ;; Enable phpinspect-mode + (phpinspect-mode)) +=20=20=20=20 + (add-hook \\=3D'php-mode-hook #\\=3D'my-php-personal-hook) =20 =20 Example configuration for `company-mode': =20 - (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 l= ine: - ;; (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)) - - ;; 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 c= ode. - (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)) - - (add-hook 'php-mode-hook #'my-php-personal-hook) - -;; End example configuration." + (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) +=20=20=20=20 + ;; If you don't have company-mode enabled by default, uncomment this= line: + ;; (company-mode) +=20=20=20=20 + ;; 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 \\=3D'(phpinspect-company-backend)) +=20=20=20=20 + ;; Shortcut to add use statements for classes you use. + (define-key php-mode-map (kbd \"C-c u\") #\\=3D'phpinspect-fix-impor= ts) +=20=20=20=20 + ;; 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\") #\\=3D'phpinspect-find-class-file) + (global-set-key (kbd \"C-c c\") #\\=3D'phpinspect-find-own-class-fil= e) +=20=20=20=20 + ;; Enable phpinspect-mode + (phpinspect-mode)) +=20=20=20=20 + (add-hook \\=3D'php-mode-hook #\\=3D'my-php-personal-hook) + + ;; End example configuration." :after-hook (phpinspect--mode-function)) =20 (defun phpinspect--suggest-at-point () diff --git a/test/phpinspect-test-env.el b/test/phpinspect-test-env.el index 6bb0aef0da..8325721af8 100644 --- a/test/phpinspect-test-env.el +++ b/test/phpinspect-test-env.el @@ -2,6 +2,7 @@ =20 (require 'phpinspect-worker) (require 'phpinspect-cache) +(require 'phpinspect-parser) =20 ;; Make sure that the worker is running. TODO: fully encapsulate the worke= r the ;; data types that are used in tests so that we don't depend on some global @@ -10,18 +11,12 @@ (phpinspect-purge-cache) =20 (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.") =20 =20 (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.") =20 (defun phpinspect-test-read-fixture-data (name) @@ -32,7 +27,7 @@ (defun phpinspect-test-read-fixture-serialization (name) (with-temp-buffer (insert-file-contents-literally (concat phpinspect-test-php-file-direc= tory "/" name ".eld")) - (eval (read (current-buffer))))) + (eval (read (current-buffer)) t))) =20 (defun phpinspect-test-parse-fixture-code (name) (phpinspect-parse-file diff --git a/test/phpinspect-test.el b/test/phpinspect-test.el index 74435e30d1..aa82c488e3 100644 --- a/test/phpinspect-test.el +++ b/test/phpinspect-test.el @@ -27,8 +27,8 @@ (require 'phpinspect) =20 (require 'phpinspect-test-env - (concat (file-name-directory (or load-file-name buffer-file-name)) - "phpinspect-test-env.el")) + (expand-file-name "phpinspect-test-env.el" + (file-name-directory (macroexp-file-name)))) =20 (ert-deftest phpinspect-get-variable-type-in-block () (let* ((code "class Foo { function a(\\Thing $baz) { $foo =3D new \\Date= Time(); $bar =3D $foo; Whatever comes after don't matter.") diff --git a/test/test-autoload.el b/test/test-autoload.el index 7f51a22020..42eb08db45 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) =20 (ert-deftest phpinspect-filename-to-typename () (should (eq (phpinspect-intern-name "\\Foo\\Bar") (phpinspect-filename-t= o-typename "src/" "src/Foo////////Bar.php"))) @@ -36,6 +37,7 @@ =20 (ert-deftest phpinspect-find-composer-json-files () (let* ((fs (phpinspect-make-virtual-fs)) + ;; FIXME: `autoloader' is not used? (autoloader (phpinspect-make-autoloader :fs fs :project-root-resolver (lambda () "/root") @@ -57,12 +59,13 @@ =20 (let ((sorter (lambda (file1 file2) (string-lessp (cdr file1) (cdr fil= e2))))) =20 - (should (equal (sort '((vendor . "/root/vendor/apples/pears/composer.j= son") - (vendor . "/root/vendor/runescape/client/compos= er.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/compose= r.json") + (vendor . "/root/vendor/runescape/client/com= poser.json") + (local . "/root/composer.json"))) + sorter) + (sort (phpinspect-find-composer-json-files fs "/root") + sorter)))))) =20 (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; -*- =20 (require 'phpinspect-bmap) =20 @@ -6,7 +7,6 @@ (bmap2 (phpinspect-make-bmap)) (bmap3 (phpinspect-make-bmap)) (token '(:token)) - (token1 '(:token1)) (token2 '(:token2)) (token3 '(:token3))) =20 @@ -69,13 +69,15 @@ (phpinspect-bmap-register bmap 9 20 '(:node3)) (phpinspect-bmap-register bmap 21 44 '(:node4)) =20 - (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)))))) =20 (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 5d98719418..64442f9814 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)) - "phpinspect-test-env.el")) + (expand-file-name "phpinspect-test-env.el" + (file-name-directory (macroexp-file-name)))) =20 (ert-deftest phpinspect-buffer-region-lookups () - (let* ((parsed) - (class)) + (let* ((parsed)) (with-temp-buffer (insert-file-contents (concat phpinspect-test-php-file-directory "/N= amespacedClass.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 "/N= amespacedClass.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)))) =20 (should (cdr parsed)))) =20 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)))) =20 (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) =20 (should (equal (list (cons 10 15)) (phpinspect-edtrack-taint-pool trac= k))) diff --git a/test/test-index.el b/test/test-index.el index 232cc1c9ae..bd2c2cde2c 100644 --- a/test/test-index.el +++ b/test/test-index.el @@ -24,6 +24,10 @@ ;;; Code: (require 'ert) (require 'phpinspect-index) +(require 'phpinspect-parse-context) +(require 'phpinspect-bmap) +(require 'phpinspect-parser) +(require 'phpinspect-test-env) =20 (ert-deftest phpinspect-index-static-methods () (let* ((class-tokens @@ -92,8 +96,9 @@ return StaticThing::create(new ThingFactory())->makeThing= ((((new Potato())->anti (should (equal (mapcar #'phpinspect-intern-name (sort - '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" "ExtendedT= hing" - "StaticThing" "Thing" "ThingFactory" "Potato" "Oth= erThing") + (copy-sequence + '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" "Extended= Thing" + "StaticThing" "Thing" "ThingFactory" "Potato" "Ot= herThing")) #'string<)) (sort used-types (lambda (s1 s2) (string< (symbol-name s1) (s= ymbol-name s2)))))))) =20 @@ -172,7 +177,7 @@ return StaticThing::create(new ThingFactory())->makeThi= ng((((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 "/I= ndexClass1.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-cur= rent-buffer)))) (let* ((index1 (phpinspect--index-tokens tree 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) =20 (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..198998419e 100644 --- a/test/test-parser.el +++ b/test/test-parser.el @@ -24,20 +24,17 @@ ;;; Code: =20 (require 'phpinspect-parser) +(require 'phpinspect-index) +(require 'phpinspect-test-env) =20 +;; FIXME: Duplicate in phpinspect-test-env.el! (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.") =20 =20 (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.") =20 =20 diff --git a/test/test-pipeline.el b/test/test-pipeline.el index f9c1ed04a3..d7285825c1 100644 --- a/test/test-pipeline.el +++ b/test/test-pipeline.el @@ -25,14 +25,15 @@ =20 (require 'phpinspect-pipeline) =20 +(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) =20 (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))) =20 +(defun phpinspect--aah-it-broke (input) + (signal 'it-brokey input)) + (ert-deftest phpinspect-pipeline-error () - (defun aah-it-broke (input) - (signal 'it-brokey input)) =20 (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))) diff --git a/test/test-project.el b/test/test-project.el index b421eebc7c..0b03df5eb2 100644 --- a/test/test-project.el +++ b/test/test-project.el @@ -35,11 +35,11 @@ (ert-deftest phpinspect-project-watch-file-and-purge () (let* ((root (make-temp-file "phpinspect-test" 'dir)) (fs (phpinspect-make-fs)) - (worker (phpinspect-make-worker)) + (_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))) + #'ignore) =20 (phpinspect-project-purge project) =20 diff --git a/test/test-resolvecontext.el b/test/test-resolvecontext.el index 894f684080..72888cd845 100644 --- a/test/test-resolvecontext.el +++ b/test/test-resolvecontext.el @@ -1,5 +1,8 @@ +;; -*- lexical-binding: t; -*- =20 (require 'phpinspect-resolvecontext) +(require 'phpinspect) +(require 'phpinspect-test-env) =20 (ert-deftest phinspect-get-resolvecontext () (let* ((ctx (phpinspect-make-pctx :incremental t :bmap (phpinspect-make-= bmap))) @@ -29,7 +32,7 @@ class TestClass { =20 (ert-deftest phpinspect-type-resolver-for-resolvecontext () (with-temp-buffer - (insert-file-contents (concat phpinspect-test-php-file-directory "/Inc= ompleteClass.php")) + (insert-file-contents (expand-file-name "IncompleteClass.php" phpinspe= ct-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-resolveconte= xt @@ -81,8 +84,8 @@ class TestClass { =20 (ert-deftest phpinspect-type-resolver-for-resolvecontext-multiple-namespac= e-blocks () (with-temp-buffer - (insert-file-contents (concat phpinspect-test-php-file-directory "/Inc= ompleteClassMultipleNamespaces.php")) - (let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string))) + (insert-file-contents (expand-file-name "IncompleteClassMultipleNamesp= aces.php" phpinspect-test-php-file-directory)) + (let* ((_bmap (phpinspect-parse-string-to-bmap (buffer-string))) (resolvecontext (phpinspect--get-resolvecontext (phpinspect-test-read-fixture-data "IncompleteClassMultipleNamespaces"))) 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=3D "twelve" (phpinspect-splayt-find tree 12))) (should (string=3D "eleven" (phpinspect-splayt-find tree 11))) =20 - (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)) =20 (phpinspect-splayt-traverse (item tree) @@ -91,7 +91,7 @@ (phpinspect-splayt-insert tree 4 "four") (phpinspect-splayt-insert tree 1 "one") =20 - (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)) =20 (phpinspect-splayt-traverse (item tree) @@ -161,7 +161,7 @@ (phpinspect-splayt-insert tree 1 "one") =20 =20 - (should (equal (sort '("eight" "nine" "eleven" "twelve") #'string-less= p) + (should (equal (sort (copy-sequence '("eight" "nine" "eleven" "twelve"= )) #'string-lessp) (sort (phpinspect-splayt-find-all-after tree 7) #'strin= g-lessp))))) =20 (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 @@ =20 (require 'phpinspect-toc) (require 'phpinspect-splayt) +(require 'phpinspect-meta) =20 (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 @@ =20 ;;; Code: =20 +(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 @@ =20 ;;; Code: =20 +(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) =20 -(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))) --=-=-=--