Fix, rename & move doom/run-tests => doom-run-tests
This commit is contained in:
parent
fac587d21e
commit
cbfb3eeda4
3 changed files with 70 additions and 62 deletions
6
Makefile
6
Makefile
|
@ -43,14 +43,14 @@ clean-pcache:
|
||||||
@$(EMACS) -l persistent-soft --eval '(delete-directory pcache-directory t)'
|
@$(EMACS) -l persistent-soft --eval '(delete-directory pcache-directory t)'
|
||||||
|
|
||||||
test: init.el .local/autoloads.el
|
test: init.el .local/autoloads.el
|
||||||
@$(EMACS) -f doom/run-tests
|
@$(EMACS) -f doom-run-tests
|
||||||
|
|
||||||
test\:core $(patsubst %, test\:%, $(MODULES)): init.el .local/autoloads.el
|
test\:core $(patsubst %, test\:%, $(MODULES)): init.el .local/autoloads.el
|
||||||
@$(EMACS) -f doom/run-tests -- $(subst test:, , $@)
|
@$(EMACS) -f doom-run-tests -- $(subst test:, , $@)
|
||||||
|
|
||||||
# run tests interactively
|
# run tests interactively
|
||||||
testi: init.el .local/autoloads.el
|
testi: init.el .local/autoloads.el
|
||||||
@$(EMACSI) -f doom/run-tests -f ert
|
@$(EMACSI) -f doom-run-tests -f ert
|
||||||
|
|
||||||
# For running Emacs from a different folder than ~/.emacs.d
|
# For running Emacs from a different folder than ~/.emacs.d
|
||||||
run:
|
run:
|
||||||
|
|
|
@ -13,3 +13,70 @@
|
||||||
finally return (intern (format "%s::%s" path name))) ()
|
finally return (intern (format "%s::%s" path name))) ()
|
||||||
()
|
()
|
||||||
,@body)))
|
,@body)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom-run-tests (&optional modules)
|
||||||
|
"Run all loaded tests, specified by MODULES (a list of module cons cells) or
|
||||||
|
command line args following a double dash (each arg should be in the
|
||||||
|
'module/submodule' format).
|
||||||
|
|
||||||
|
If neither is available, run all tests in all enabled modules."
|
||||||
|
(interactive) ;; TODO Add completing-read selection of tests
|
||||||
|
;; FIXME Refactor this
|
||||||
|
(condition-case-unless-debug ex
|
||||||
|
(let (targets)
|
||||||
|
;; ensure DOOM is initialized
|
||||||
|
(let (noninteractive)
|
||||||
|
(unload-feature 'core t)
|
||||||
|
(load (expand-file-name "init.el" user-emacs-directory) nil t))
|
||||||
|
(run-hooks 'emacs-startup-hook)
|
||||||
|
;; collect targets
|
||||||
|
(cond ((and command-line-args-left
|
||||||
|
(equal (car command-line-args-left) "--"))
|
||||||
|
(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
|
||||||
|
command-line-args-left 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)))
|
||||||
|
|
||||||
|
(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 (directory-files-recursively dir "\\.el$"))
|
||||||
|
into items
|
||||||
|
finally do (quiet! (mapc #'load-file items)))
|
||||||
|
;; run all loaded tests
|
||||||
|
(when noninteractive
|
||||||
|
(ert-run-tests-batch-and-exit)))
|
||||||
|
('error
|
||||||
|
(lwarn 'doom-test :error
|
||||||
|
"%s -> %s"
|
||||||
|
(car ex) (error-message-string ex)))))
|
||||||
|
|
|
@ -602,65 +602,6 @@ package files."
|
||||||
and do (message "Deleted %s" (file-relative-name path)))
|
and do (message "Deleted %s" (file-relative-name path)))
|
||||||
(message "Everything is clean"))))
|
(message "Everything is clean"))))
|
||||||
|
|
||||||
(defun doom/run-tests (&optional modules)
|
|
||||||
"Run all loaded tests, specified by MODULES (a list of module cons cells) or
|
|
||||||
command line args following a double dash (each arg should be in the
|
|
||||||
'module/submodule' format).
|
|
||||||
|
|
||||||
If neither is available, run all tests in all enabled modules."
|
|
||||||
(interactive) ;; TODO Add completing-read selection of tests
|
|
||||||
;; FIXME Refactor this
|
|
||||||
(condition-case-unless-debug ex
|
|
||||||
(let (targets)
|
|
||||||
;; ensure DOOM is initialized
|
|
||||||
(let (noninteractive)
|
|
||||||
(unload-feature 'core t)
|
|
||||||
(load (expand-file-name "init.el" user-emacs-directory) nil t))
|
|
||||||
(run-hooks 'emacs-startup-hook)
|
|
||||||
;; collect targets
|
|
||||||
(cond ((and command-line-args-left
|
|
||||||
(equal (car command-line-args-left) "--"))
|
|
||||||
(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 cdr) (split-string arg "/" t)
|
|
||||||
(cons (intern (concat ":" car))
|
|
||||||
(and (cadr consp) (intern cdr))))
|
|
||||||
into args
|
|
||||||
finally do (setq modules args
|
|
||||||
command-line-args-left 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)))
|
|
||||||
|
|
||||||
(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
|
|
||||||
collect (doom-module-path module submodule "test/")))
|
|
||||||
for dir in targets
|
|
||||||
if (file-directory-p dir)
|
|
||||||
nconc (reverse (directory-files-recursively dir "\\.el$"))
|
|
||||||
into items
|
|
||||||
finally do (quiet! (mapc #'load-file items)))
|
|
||||||
;; run all loaded tests
|
|
||||||
(when noninteractive
|
|
||||||
(ert-run-tests-batch-and-exit)))
|
|
||||||
('error
|
|
||||||
(lwarn 'doom-test :error
|
|
||||||
"%s -> %s"
|
|
||||||
(car ex) (error-message-string ex)))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Package.el modifications
|
;; Package.el modifications
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue