Fix doom//run-tests

This commit is contained in:
Henrik Lissner 2018-05-24 21:15:44 +02:00
parent 2a8da07e31
commit b70ed84a33
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -7,43 +7,46 @@ command line args following a double dash (each arg should be in the
If neither is available, run all tests in all enabled modules." If neither is available, run all tests in all enabled modules."
(interactive) (interactive)
(doom//reload-autoloads)
(let (noninteractive) (let (noninteractive)
;; Core libraries aren't fully loaded in a noninteractive session, so we ;; Core libraries aren't fully loaded in a noninteractive session, so we
;; reload it with `noninteractive' set to nil to force them to. ;; reload it with `noninteractive' set to nil to force them to.
(doom-initialize)) (doom-initialize t)
(doom-initialize-modules t))
(condition-case-unless-debug ex (condition-case-unless-debug ex
(let ((target-paths (let* ((doom-modules (doom-module-table))
;; Convert targets (either from MODULES or `argv') into a list of (target-paths
;; string paths, pointing to the root directory of modules ;; Convert targets (either from MODULES or `argv') into a list of
(cond ((stringp (car modules)) ; command line ;; string paths, pointing to the root directory of modules
(save-match-data (cond ((stringp (car modules)) ; command line
(cl-loop for arg in modules (save-match-data
if (string= arg "core") collect doom-core-dir (cl-loop for arg in modules
else if (string-match-p "/" arg) if (string= arg ":core") collect doom-core-dir
nconc (cl-loop for dir in doom-modules-dirs else if (string-match-p "/" arg)
collect (expand-file-name arg dir)) nconc (cl-loop for dir in doom-modules-dirs
else collect (expand-file-name arg dir))
nconc (cl-loop for dir in doom-modules-dirs else
for path = (expand-file-name arg dir) nconc (cl-loop for dir in doom-modules-dirs
if (file-directory-p path) for path = (expand-file-name arg dir)
nconc if (file-directory-p path)
(cl-remove-if-not nconc
#'file-directory-p (cl-remove-if-not
(directory-files path t "^[^.]" t))) #'file-directory-p
finally do (setq argv nil)))) (directory-files path t "^[^.]" t)))
finally do (setq argv nil))))
(modules ; cons-cells given to MODULES (modules ; cons-cells given to MODULES
(cl-loop for (module . submodule) in modules (cl-loop for (module . submodule) in modules
if (doom-module-locate-path module submodule) if (doom-module-locate-path module submodule)
collect it)) collect it))
((append (list doom-core-dir) ((append (list doom-core-dir)
(doom-module-load-path)))))) (doom-module-load-path))))))
;; Load all the unit test files... ;; Load all the unit test files...
(dolist (path target-paths) (dolist (path target-paths)
(let ((test-path (expand-file-name "test/" path))) (let ((test-path (expand-file-name "test/" path)))
(when (file-directory-p test-path) (when (file-directory-p test-path)
(dolist (test-file (reverse (doom-files-under test-path :match "\\.el$"))) (dolist (test-file (reverse (doom-files-in test-path :match "\\.el$" :full t)))
(load test-file nil :noerror))))) (load test-file nil :noerror)))))
;; ... then run them ;; ... then run them
(switch-to-buffer (get-buffer-create "*blank*")) (switch-to-buffer (get-buffer-create "*blank*"))