💥 Replace package.el/quelpa with straight #374

There are a few kinks to iron out, but for the most part it's done. Doom
Emacs, powered by straight. Goodbye gnutls and elpa/quelpa issues.

This update doesn't come with rollback or lockfile support yet, but I
will eventually include one with Doom, and packages will be (by default,
anyway) updated in sync with Doom.

Relevant threads: #1577 #1566 #1473
This commit is contained in:
Henrik Lissner 2019-07-21 15:39:45 +02:00
parent 492f2dea1e
commit b90dede1ab
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
35 changed files with 1542 additions and 1771 deletions

View file

@ -1,67 +1,73 @@
;;; core/cli/test.el -*- lexical-binding: t; -*-
(dispatcher! test (doom-run-tests args)
(def-command! test ()
"Run Doom unit tests.")
;;
;; Library
;;; Library
(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).
(defun doom-run-tests ()
"Discover and load test files, then run all defined suites.
If neither is available, run all tests in all enabled modules."
;; Core libraries aren't fully loaded in a noninteractive session, so we
;; reload it with `noninteractive' set to nil to force them to.
(let* ((noninteractive t)
(doom-modules (doom-modules)))
(quiet! (doom-reload-autoloads))
(let ((target-paths
;; Convert targets 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 (mapcar (apply-partially #'expand-file-name arg)
doom-modules-dirs)
else
nconc (cl-loop for dir in doom-modules-dirs
for path = (expand-file-name arg dir)
if (file-directory-p path)
nconc (doom-files-in path :type 'dirs :depth 1 :full t :sort nil))
finally do (setq argv nil))))
(modules ; cons-cells given to MODULES
(cl-loop for (module . submodule) in modules
if (doom-module-locate-path module submodule)
collect it))
((append (list doom-core-dir)
(doom-module-load-path))))))
;; Load all the unit test files...
(require 'buttercup)
(mapc (lambda (file) (load file :noerror (not doom-debug-mode)))
(doom-files-in (mapcar (apply-partially #'expand-file-name "test/")
target-paths)
:match "\\.el$" :full t))
;; ... then run them
(when doom-debug-mode
(setq buttercup-stack-frame-style 'pretty))
(let ((split-width-threshold 0)
(split-height-threshold 0)
(window-min-width 0)
(window-min-height 0))
(buttercup-run)))))
Takes directories as command line arguments, defaulting to the
current directory."
(let ((dirs nil)
(patterns nil)
(args command-line-args-left)
(doom-modules (doom-modules)))
(doom-initialize-autoloads doom-autoload-file)
(doom-initialize-autoloads doom-package-autoload-file)
(while args
(cond
;; ((member (car args) '("--traceback"))
;; (when (not (cdr args))
;; (error "Option requires argument: %s" (car args)))
;; ;; Make sure it's a valid style by trying to format a dummy
;; ;; frame with it
;; (buttercup--format-stack-frame '(t myfun 1 2) (intern (cadr args)))
;; (setq buttercup-stack-frame-style (intern (cadr args)))
;; (setq args (cddr args)))
;; ((member (car args) '("-p" "--pattern"))
;; (when (not (cdr args))
;; (error "Option requires argument: %s" (car args)))
;; (push (cadr args) patterns)
;; (setq args (cddr args)))
;; ((member (car args) '("-c" "--no-color"))
;; (setq buttercup-color nil)
;; (setq args (cdr args)))
(t
(push (car args) dirs)
(setq args (cdr args)))))
(setq command-line-args-left nil)
(dolist (dir (or dirs '(".")))
(setq dir (if (string= dir "core")
doom-core-dir
(expand-file-name dir doom-modules-dir)))
(let ((test-dir (expand-file-name "test" dir)))
(when (or (string= dir doom-core-dir)
(cl-destructuring-bind (category . module)
(or (doom-module-from-path dir)
(cons nil nil))
(and category module (doom-module-p category module))))
(dolist (file (nreverse (doom-glob test-dir "test-*.el")))
(when (doom-file-cookie-p file)
(load file nil t))))))
(when patterns
(dolist (spec (buttercup--specs buttercup-suites))
(let ((spec-full-name (buttercup-spec-full-name spec)))
(unless (cl-dolist (p patterns)
(when (string-match p spec-full-name)
(cl-return t)))
(setf (buttercup-spec-function spec)
(lambda () (signal 'buttercup-pending "SKIPPED")))))))
(buttercup-run)))
;;
;; Test library
(defmacro insert! (&rest text)
(defmacro insert!! (&rest text)
"Insert TEXT in buffer, then move cursor to last {0} marker."
`(progn
(insert ,@text)