💥 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
|
@ -148,7 +148,8 @@ ready to be pasted in a bug report on github."
|
|||
(or (ignore-errors
|
||||
(cl-delete-duplicates
|
||||
(cl-loop for file in (append (reverse (directory-files-recursively doom-core-dir "\\.elc$"))
|
||||
(reverse (directory-files-recursively doom-modules-dir "\\.elc$")))
|
||||
(cl-loop for dir in doom-modules-dirs
|
||||
nconc (directory-files-recursively dir "\\.elc$")))
|
||||
collect (file-relative-name (file-name-directory file) doom-emacs-dir))
|
||||
:test #'equal))
|
||||
"n/a")
|
||||
|
|
|
@ -68,9 +68,8 @@ in."
|
|||
(let ((sexp (sexp-at-point)))
|
||||
(when (memq (car-safe sexp) '(featurep! require!))
|
||||
(format "%s %s" (nth 1 sexp) (nth 2 sexp))))))
|
||||
((and buffer-file-name
|
||||
(file-in-directory-p buffer-file-name doom-modules-dir))
|
||||
(let ((module (doom-module-from-path buffer-file-name)))
|
||||
(buffer-file-name
|
||||
(when-let* ((module (doom-module-from-path buffer-file-name)))
|
||||
(format "%s %s" (car module) (cdr module)))))))
|
||||
(list (completing-read "Describe module: "
|
||||
(cl-loop for (module . sub) in (reverse (hash-table-keys doom-modules))
|
||||
|
|
|
@ -84,9 +84,13 @@ interactive session."
|
|||
(defmacro warn! (message &rest args)
|
||||
"Output a colored warning for the current module in the *Messages* buffer."
|
||||
(let ((load-file-name (or load-file-name byte-compile-current-file)))
|
||||
(if (file-in-directory-p load-file-name doom-modules-dir)
|
||||
`(cl-destructuring-bind (cat . mod) (doom-module-from-path ,load-file-name)
|
||||
(delay-warning (format "%s %s" cat mod) (format ,message ,@args) :warning))
|
||||
(if (cl-loop for dir in doom-modules-dirs
|
||||
if (file-in-directory-p load-file-name dir)
|
||||
return t)
|
||||
`(cl-destructuring-bind (cat . mod)
|
||||
(doom-module-from-path ,load-file-name)
|
||||
(delay-warning (format "%s %s" cat mod) (format ,message ,@args)
|
||||
:warning))
|
||||
`(delay-warning (file-relative-name load-file-name doom-emacs-dir)
|
||||
(format ,message ,@args) :warning))))
|
||||
|
||||
|
|
|
@ -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