New bin/doom (eventual replacement for make)

This commit adds bin/doom, which acts as the middle man that make once
was (and will stay for a while, though the documentation will shift away
from using it). It does everything the previous make interface did, but
is faster and more flexible. bin/doom should eventually replace the
makefile.

bin/doom also makes it easier to run Doom outside of ~/.emacs.d and
~/.doom.d with, for example:

  bin/doom run -p ~/.other.doom.d/ -e ~/.other.emacs.d

bin/doom.cmd is included for Windows users, but I don't recommend using
it yet. It hasn't been tested nor have I ever written a batch script
before.

Also update init.example.el with new defaults.
This commit is contained in:
Henrik Lissner 2018-05-20 12:21:13 +02:00
parent da5c7d27cf
commit f058505306
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
14 changed files with 493 additions and 170 deletions

View file

@ -1,6 +1,5 @@
;;; core/autoload/test.el -*- lexical-binding: t; no-byte-compile: t; -*-
;;;###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
@ -8,56 +7,53 @@ 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)
(let ((doom-modules (make-hash-table :test #'equal)))
;; ensure DOOM is initialized
(let (noninteractive)
;; Core libraries aren't fully loaded in a noninteractive session, so we
;; reload it with `noninteractive' set to nil to force them to.
(doom-initialize t)
(run-hooks 'doom-init-hook 'pre-command-hook 'doom-after-switch-buffer-hook))
(condition-case-unless-debug ex
(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
(save-match-data
(cl-loop for arg in (cdr argv)
if (string= arg "core") collect doom-core-dir
else if (string-match-p "/" arg)
nconc (cl-loop for dir in doom-modules-dirs
collect (expand-file-name arg dir))
else
nconc (cl-loop for dir in doom-modules-dirs
for path = (expand-file-name arg dir)
if (file-directory-p path)
nconc
(cl-remove-if-not
#'file-directory-p
(directory-files path t "^[^.]" t)))
finally do (setq argv nil))))
(let (noninteractive)
;; Core libraries aren't fully loaded in a noninteractive session, so we
;; reload it with `noninteractive' set to nil to force them to.
(doom-initialize))
(condition-case-unless-debug ex
(let ((target-paths
;; Convert targets (either from MODULES or `argv') into a list of
;; string paths, pointing to the root directory of modules
(cond ((stringp (car modules)) ; command line
(save-match-data
(cl-loop for arg in modules
if (string= arg "core") collect doom-core-dir
else if (string-match-p "/" arg)
nconc (cl-loop for dir in doom-modules-dirs
collect (expand-file-name arg dir))
else
nconc (cl-loop for dir in doom-modules-dirs
for path = (expand-file-name arg dir)
if (file-directory-p path)
nconc
(cl-remove-if-not
#'file-directory-p
(directory-files path t "^[^.]" t)))
finally do (setq argv nil))))
(modules ; cons-cells given to MODULES
(cl-loop for (module . submodule) in modules
if (doom-module-find-path module submodule)
collect it))
(modules ; cons-cells given to MODULES
(cl-loop for (module . submodule) in modules
if (doom-module-locate-path module submodule)
collect it))
((let (noninteractive)
(load (expand-file-name "init.test.el" user-emacs-directory) nil t)
(append (list doom-core-dir) (doom-module-load-path)))))))
;; Load all the unit test files...
(dolist (path target-paths)
(let ((test-path (expand-file-name "test/" path)))
(when (file-directory-p test-path)
(dolist (test-file (reverse (doom-packages--files test-path "\\.el$")))
(load test-file nil :noerror)))))
;; ... then run them
(if noninteractive
(ert-run-tests-batch-and-exit)
(call-interactively #'ert-run-tests-interactively)))
('error
(lwarn 'doom-test :error
"%s -> %s"
(car ex) (error-message-string ex))))))
((append (list doom-core-dir)
(doom-module-load-path))))))
;; Load all the unit test files...
(dolist (path target-paths)
(let ((test-path (expand-file-name "test/" path)))
(when (file-directory-p test-path)
(dolist (test-file (reverse (doom-files-under test-path :match "\\.el$")))
(load test-file nil :noerror)))))
;; ... then run them
(switch-to-buffer (get-buffer-create "*blank*"))
(if noninteractive
(ert-run-tests-batch-and-exit)
(call-interactively #'ert-run-tests-interactively)))
('error
(lwarn 'doom-test :error
"%s -> %s"
(car ex) (error-message-string ex)))))
;; --- Test helpers -----------------------