2018-09-07 21:49:49 -04:00
|
|
|
;;; core/cli/test.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-09-03 00:41:03 -04:00
|
|
|
(defun doom--emacs-binary ()
|
|
|
|
(let ((emacs-binary-path (doom-path invocation-directory invocation-name))
|
|
|
|
(runemacs-binary-path (if IS-WINDOWS (doom-path invocation-directory "runemacs.exe"))))
|
|
|
|
(if (and runemacs-binary-path (file-exists-p runemacs-binary-path))
|
|
|
|
runemacs-binary-path
|
|
|
|
emacs-binary-path)))
|
|
|
|
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
|
2019-08-27 00:06:46 -04:00
|
|
|
(defcli! test (&rest targets)
|
|
|
|
"Run Doom unit tests."
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
:bare t
|
|
|
|
(doom-initialize 'force)
|
|
|
|
(require 'ansi-color)
|
|
|
|
(let (files error read-files)
|
2019-08-27 00:06:46 -04:00
|
|
|
(unless targets
|
|
|
|
(setq targets
|
|
|
|
(cons doom-core-dir
|
|
|
|
(cl-remove-if-not
|
2019-11-07 21:36:18 -05:00
|
|
|
(doom-rpartial #'file-in-directory-p doom-emacs-dir)
|
2019-08-27 00:06:46 -04:00
|
|
|
;; Omit `doom-private-dir', which is always first
|
|
|
|
(let (doom-modules)
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
(load (expand-file-name "test/init" doom-core-dir) nil t)
|
2019-08-27 00:06:46 -04:00
|
|
|
(cdr (doom-module-load-path)))))))
|
|
|
|
(while targets
|
|
|
|
(let ((target (pop targets)))
|
2019-09-03 00:41:03 -04:00
|
|
|
;; FIXME Module targets don't work
|
2019-08-27 00:06:46 -04:00
|
|
|
(cond ((equal target ":core")
|
|
|
|
(appendq! files (nreverse (doom-glob doom-core-dir "test/test-*.el"))))
|
|
|
|
((file-directory-p target)
|
|
|
|
(setq target (expand-file-name target))
|
|
|
|
(appendq! files (nreverse (doom-glob target "test/test-*.el"))))
|
|
|
|
((file-exists-p target)
|
|
|
|
(push target files)))))
|
|
|
|
(with-temp-buffer
|
|
|
|
(print! (start "Bootstrapping test environment, if necessary..."))
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
(cl-destructuring-bind (status . output)
|
|
|
|
(doom-exec-process
|
|
|
|
(doom--emacs-binary)
|
|
|
|
"--batch"
|
|
|
|
"--eval"
|
|
|
|
(prin1-to-string
|
|
|
|
`(progn
|
|
|
|
(setq doom-emacs-dir ,doom-emacs-dir
|
|
|
|
doom-local-dir ,(concat doom-local-dir "test/")
|
|
|
|
doom-private-dir ,(concat doom-core-dir "test/")
|
|
|
|
doom-auto-accept t)
|
|
|
|
(require 'core ,(locate-library "core"))
|
|
|
|
(require 'core-cli)
|
|
|
|
(doom-initialize 'force)
|
|
|
|
(doom-initialize-modules)
|
|
|
|
(doom-cli-reload-core-autoloads 'force)
|
|
|
|
(when (doom-cli-packages-install)
|
|
|
|
(doom-cli-reload-package-autoloads 'force)))))
|
|
|
|
(unless (zerop status)
|
|
|
|
(error "Failed to bootstrap unit tests"))))
|
|
|
|
(with-temp-buffer
|
|
|
|
(dolist (file files)
|
|
|
|
(if (doom-file-cookie-p file "if" t)
|
|
|
|
(cl-destructuring-bind (_status . output)
|
|
|
|
(apply #'doom-exec-process
|
|
|
|
(doom--emacs-binary)
|
|
|
|
"--batch"
|
|
|
|
"-l" (concat doom-core-dir "core.el")
|
|
|
|
"-l" (concat doom-core-dir "test/helpers.el")
|
|
|
|
(append (when (file-in-directory-p file doom-modules-dir)
|
|
|
|
(list "-f" "doom-initialize-core"))
|
|
|
|
(list "-l" file
|
|
|
|
"-f" "buttercup-run")))
|
|
|
|
(insert (replace-regexp-in-string ansi-color-control-seq-regexp "" output))
|
|
|
|
(push file read-files))
|
|
|
|
(print! (info "Ignoring %s" (relpath file)))))
|
|
|
|
(let ((total 0)
|
|
|
|
(total-failed 0)
|
|
|
|
(i 0))
|
|
|
|
(print! "\n----------------------------------------\nTests finished")
|
|
|
|
(print-group!
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^Ran \\([0-9]+\\) specs, \\([0-9]+\\) failed," nil t)
|
|
|
|
(let ((ran (string-to-number (match-string 1)))
|
|
|
|
(failed (string-to-number (match-string 2))))
|
|
|
|
(when (> failed 0)
|
|
|
|
(terpri)
|
|
|
|
(print! (warn "(%s) Failed %d/%d tests")
|
|
|
|
(path (nth i read-files))
|
|
|
|
failed ran)
|
|
|
|
(save-excursion
|
|
|
|
(print-group!
|
|
|
|
(print!
|
|
|
|
"%s" (string-trim
|
|
|
|
(buffer-substring
|
|
|
|
(match-beginning 0)
|
|
|
|
(dotimes (_ failed (point))
|
|
|
|
(search-backward "========================================"))))))))
|
|
|
|
(cl-incf total ran)
|
|
|
|
(cl-incf total-failed failed)
|
|
|
|
(cl-incf i))))
|
|
|
|
(terpri)
|
|
|
|
(if (= total-failed 0)
|
|
|
|
(print! (success "Ran %d tests successfully." total total-failed))
|
|
|
|
(print! (error "Ran %d tests, %d failed") total total-failed)
|
|
|
|
(kill-emacs 1)))
|
2019-08-27 00:06:46 -04:00
|
|
|
t)))
|