💥 Redesign private sub-module system
~/.doom.d/modules is now a full module tree, like ~/.emacs.d/modules. Symlinks are no longer involved. Private modules can now shadow Doom modules. e.g. ~/.doom.d/modules/lang/org will take precendence over ~/.emacs.d/modules/lang/org. Also, made doom--*-load-path variables public (e.g. doom--site-load-path => doom-site-load-path), and rearranged the load-path for a 10-15% startup boost.
This commit is contained in:
parent
8ca4fbd8fe
commit
2b1c323dbf
12 changed files with 122 additions and 145 deletions
|
@ -8,57 +8,33 @@ command line args following a double dash (each arg should be in the
|
|||
|
||||
If neither is available, run all tests in all enabled modules."
|
||||
(interactive)
|
||||
;; ensure DOOM is initialized
|
||||
(doom-initialize-packages t)
|
||||
(condition-case-unless-debug ex
|
||||
(let (targets)
|
||||
;; ensure DOOM is initialized
|
||||
(let (noninteractive)
|
||||
(load (expand-file-name "core/core.el" user-emacs-directory) nil t))
|
||||
;; collect targets
|
||||
(cond ((and argv (equal (car argv) "--"))
|
||||
(cl-loop for arg in (cdr argv)
|
||||
if (equal arg "core")
|
||||
do (push (expand-file-name "test/" doom-core-dir) targets)
|
||||
else
|
||||
collect
|
||||
(cl-destructuring-bind (car &optional cdr) (split-string arg "/" t)
|
||||
(cons (intern (concat ":" car))
|
||||
(and cdr (intern cdr))))
|
||||
into args
|
||||
finally do
|
||||
(setq modules args argv nil)))
|
||||
(let ((target-paths
|
||||
;; Convert targets (either from MODULES or `argv') into a list of
|
||||
;; string paths, pointing to the root directory of modules
|
||||
(cond ((string= (car argv) "--") ; command line
|
||||
(cl-loop for arg in (cdr argv)
|
||||
if (equal arg "core") collect doom-core-dir
|
||||
else collect (expand-file-name arg)
|
||||
finally do (setq argv nil)))
|
||||
|
||||
(modules
|
||||
(unless (cl-loop for module in modules
|
||||
unless (and (consp module)
|
||||
(keywordp (car module))
|
||||
(symbolp (cdr module)))
|
||||
return t)
|
||||
(error "Expected a list of cons, got: %s" modules)))
|
||||
(modules ; cons-cells given to MODULES
|
||||
(cl-loop for (module . submodule) in modules
|
||||
if (doom-module-path module submodule)
|
||||
collect it))
|
||||
|
||||
(t
|
||||
(let (noninteractive)
|
||||
(setq doom-modules (clrhash doom-modules))
|
||||
(load (expand-file-name "init.test.el" user-emacs-directory) nil t)
|
||||
(setq modules (doom-module-pairs)
|
||||
targets (list (expand-file-name "test/" doom-core-dir))))))
|
||||
;; resolve targets to a list of test files and load them
|
||||
(cl-loop with targets =
|
||||
(append targets
|
||||
(cl-loop for (module . submodule) in modules
|
||||
if submodule
|
||||
collect (doom-module-path module submodule "test/")
|
||||
else
|
||||
nconc
|
||||
(cl-loop with module-name = (substring (symbol-name module) 1)
|
||||
with module-path = (expand-file-name module-name doom-modules-dir)
|
||||
for path in (directory-files module-path t "^\\w")
|
||||
collect (expand-file-name "test/" path))))
|
||||
for dir in targets
|
||||
if (file-directory-p dir)
|
||||
nconc (reverse (doom-packages--files dir "\\.el$"))
|
||||
into items
|
||||
finally do (quiet! (mapc #'load-file items)))
|
||||
;; run all loaded tests
|
||||
((let (noninteractive)
|
||||
(setq doom-modules (clrhash doom-modules))
|
||||
(load (expand-file-name "init.test.el" user-emacs-directory) nil t)
|
||||
(append (list doom-core-dir) (doom-module-paths)))))))
|
||||
;; Load all the unit test files...
|
||||
(dolist (path target-paths)
|
||||
(when (file-directory-p (expand-file-name "test/" path))
|
||||
(dolist (test-file (reverse (doom-packages--files path "\\.el$")))
|
||||
(load test-file nil :nomessage))))
|
||||
;; ... then run them
|
||||
(if noninteractive
|
||||
(ert-run-tests-batch-and-exit)
|
||||
(call-interactively #'ert-run-tests-interactively)))
|
||||
|
@ -86,11 +62,12 @@ If neither is available, run all tests in all enabled modules."
|
|||
(when-let* ((after (plist-get plist :after)))
|
||||
(setq body `(,@body @after)))
|
||||
`(ert-deftest
|
||||
,(cl-loop with path = (file-relative-name (file-name-sans-extension load-file-name)
|
||||
doom-emacs-dir)
|
||||
for (rep . with) in '(("/test/" . "/") ("/" . ":"))
|
||||
do (setq path (replace-regexp-in-string rep with path t t))
|
||||
finally return (intern (format "%s::%s" path name)))
|
||||
,(intern (format "%s::%s"
|
||||
(if (file-in-directory-p load-file-name doom-core-dir)
|
||||
(format "core/%s" (file-name-base load-file-name))
|
||||
(replace-regexp-in-string "^.*/modules/\\([^/]+\\)/\\([^/]+\\)/test/" "\\1/\\2:"
|
||||
(file-name-sans-extension load-file-name)))
|
||||
name))
|
||||
()
|
||||
,(if (plist-get plist :skip)
|
||||
`(ert-skip ,(plist-get plist :skip))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue