1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 22:41:06 -08:00

Separate out all tests, the better to identify which one failed

This commit is contained in:
John Wiegley 2017-12-03 10:49:33 -08:00
parent 4c1b82aed5
commit e5aa510d48

View file

@ -122,19 +122,20 @@
(should (equal (use-package--normalize-function "Hello") "Hello")) (should (equal (use-package--normalize-function "Hello") "Hello"))
(should (equal (use-package--normalize-function '(nil . nil)) '(nil . nil)))) (should (equal (use-package--normalize-function '(nil . nil)) '(nil . nil))))
(ert-deftest use-package-test/:disabled () (ert-deftest use-package-test/:disabled-1 ()
(match-expansion (match-expansion
(use-package foo :disabled t) (use-package foo :disabled t)
`())) `()))
(ert-deftest use-package-test/:preface () (ert-deftest use-package-test/:preface-1 ()
(match-expansion (match-expansion
(use-package foo :preface (t)) (use-package foo :preface (t))
`(progn `(progn
(eval-and-compile (eval-and-compile
(t)) (t))
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:preface-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :preface (t)) (use-package foo :preface (t))
@ -145,8 +146,9 @@
"Cannot load foo: %S" nil "Cannot load foo: %S" nil
(load "foo" nil t))) (load "foo" nil t)))
(t)) (t))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:preface-3 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo (use-package foo
@ -167,8 +169,9 @@
(init) (init)
(require 'foo nil nil) (require 'foo nil nil)
(config) (config)
t))) t))))
(ert-deftest use-package-test/:preface-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo (use-package foo
@ -193,24 +196,20 @@
(config) (config)
t)))))) t))))))
(ert-deftest use-package-test/:pin () (ert-deftest use-package-test/:pin-1 ()
(match-expansion (match-expansion
(use-package foo :pin foo) (use-package foo :pin foo)
`(progn `(progn
(use-package-pin-package 'foo "foo") (use-package-pin-package 'foo "foo")
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:pin-2 ()
(match-expansion (match-expansion
(use-package foo :pin "foo") (use-package foo :pin "foo")
`(progn `(progn
(use-package-pin-package 'foo "foo") (use-package-pin-package 'foo "foo")
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:defer-install ()
(match-expansion
(use-package foo :defer-install t)
`(require 'foo nil nil)))
(ert-deftest use-package-test-normalize/:ensure () (ert-deftest use-package-test-normalize/:ensure ()
(flet ((norm (&rest args) (flet ((norm (&rest args)
(apply #'use-package-normalize/:ensure (apply #'use-package-normalize/:ensure
@ -221,51 +220,57 @@
(should-error (norm '(1))) (should-error (norm '(1)))
(should-error (norm '("Hello"))))) (should-error (norm '("Hello")))))
(ert-deftest use-package-test/:ensure () (ert-deftest use-package-test/:ensure-1 ()
(let ((use-package-always-ensure nil)) (let ((use-package-always-ensure nil))
(match-expansion (match-expansion
(use-package foo :ensure t) (use-package foo :ensure t)
`(progn `(progn
(use-package-ensure-elpa 'foo 't 'nil) (use-package-ensure-elpa 'foo 't 'nil)
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-2 ()
(let ((use-package-always-ensure t)) (let ((use-package-always-ensure t))
(match-expansion (match-expansion
(use-package foo :ensure t) (use-package foo :ensure t)
`(progn `(progn
(use-package-ensure-elpa 'foo 't 'nil) (use-package-ensure-elpa 'foo 't 'nil)
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-3 ()
(let ((use-package-always-ensure nil)) (let ((use-package-always-ensure nil))
(match-expansion (match-expansion
(use-package foo :ensure nil) (use-package foo :ensure nil)
`(progn `(progn
(use-package-ensure-elpa 'foo 'nil 'nil) (use-package-ensure-elpa 'foo 'nil 'nil)
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-4 ()
(let ((use-package-always-ensure t)) (let ((use-package-always-ensure t))
(match-expansion (match-expansion
(use-package foo :ensure nil) (use-package foo :ensure nil)
`(progn `(progn
(use-package-ensure-elpa 'foo 'nil 'nil) (use-package-ensure-elpa 'foo 'nil 'nil)
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-5 ()
(let ((use-package-always-ensure nil)) (let ((use-package-always-ensure nil))
(match-expansion (match-expansion
(use-package foo :load-path "foo") (use-package foo :load-path "foo")
`(progn `(progn
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-6 ()
(let ((use-package-always-ensure t)) (let ((use-package-always-ensure t))
(match-expansion (match-expansion
(use-package foo :load-path "foo") (use-package foo :load-path "foo")
`(progn `(progn
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-7 ()
(let ((use-package-always-ensure nil)) (let ((use-package-always-ensure nil))
(match-expansion (match-expansion
(use-package foo :ensure nil :load-path "foo") (use-package foo :ensure nil :load-path "foo")
@ -273,8 +278,9 @@
(use-package-ensure-elpa 'foo 'nil 'nil) (use-package-ensure-elpa 'foo 'nil 'nil)
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-8 ()
(let ((use-package-always-ensure t)) (let ((use-package-always-ensure t))
(match-expansion (match-expansion
(use-package foo :ensure nil :load-path "foo") (use-package foo :ensure nil :load-path "foo")
@ -282,8 +288,9 @@
(use-package-ensure-elpa 'foo 'nil 'nil) (use-package-ensure-elpa 'foo 'nil 'nil)
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-9 ()
(let ((use-package-always-ensure nil)) (let ((use-package-always-ensure nil))
(match-expansion (match-expansion
(use-package foo :ensure t :load-path "foo") (use-package foo :ensure t :load-path "foo")
@ -291,8 +298,9 @@
(use-package-ensure-elpa 'foo 't 'nil) (use-package-ensure-elpa 'foo 't 'nil)
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-10 ()
(let ((use-package-always-ensure t)) (let ((use-package-always-ensure t))
(match-expansion (match-expansion
(use-package foo :ensure t :load-path "foo") (use-package foo :ensure t :load-path "foo")
@ -300,8 +308,9 @@
(use-package-ensure-elpa 'foo 't 'nil) (use-package-ensure-elpa 'foo 't 'nil)
(eval-and-compile (eval-and-compile
(add-to-list 'load-path ,(pred stringp))) (add-to-list 'load-path ,(pred stringp)))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-11 ()
(let (tried-to-install) (let (tried-to-install)
(flet ((use-package-ensure-elpa (flet ((use-package-ensure-elpa
(name ensure state &optional no-refresh) (name ensure state &optional no-refresh)
@ -311,60 +320,67 @@
(use-package foo :ensure t) (use-package foo :ensure t)
(should (eq tried-to-install 'foo))))) (should (eq tried-to-install 'foo)))))
(ert-deftest use-package-test/:if () (ert-deftest use-package-test/:if-1 ()
(match-expansion (match-expansion
(use-package foo :if t) (use-package foo :if t)
`(when t `(when t
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:if-2 ()
(match-expansion (match-expansion
(use-package foo :if (and t t)) (use-package foo :if (and t t))
`(when (and t t) `(when (and t t)
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:if-3 ()
(match-expansion (match-expansion
(use-package foo :if nil) (use-package foo :if nil)
`(when nil `(when nil
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:when () (ert-deftest use-package-test/:when-1 ()
(match-expansion (match-expansion
(use-package foo :when t) (use-package foo :when t)
`(when t `(when t
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:when-2 ()
(match-expansion (match-expansion
(use-package foo :when (and t t)) (use-package foo :when (and t t))
`(when (and t t) `(when (and t t)
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:when-3 ()
(match-expansion (match-expansion
(use-package foo :when nil) (use-package foo :when nil)
`(when nil `(when nil
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:unless () (ert-deftest use-package-test/:unless-1 ()
(match-expansion (match-expansion
(use-package foo :unless t) (use-package foo :unless t)
`(when (not t) `(when (not t)
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:unless-2 ()
(match-expansion (match-expansion
(use-package foo :unless (and t t)) (use-package foo :unless (and t t))
`(when (not (and t t)) `(when (not (and t t))
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:unless-3 ()
(match-expansion (match-expansion
(use-package foo :unless nil) (use-package foo :unless nil)
`(unless nil `(unless nil
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:requires () (ert-deftest use-package-test/:requires-1 ()
(match-expansion (match-expansion
(use-package foo :requires bar) (use-package foo :requires bar)
`(when (featurep 'bar) `(when (featurep 'bar)
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:requires-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :requires bar) (use-package foo :requires bar)
@ -374,13 +390,15 @@
(with-demoted-errors (with-demoted-errors
"Cannot load foo: %S" nil "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:requires-3 ()
(match-expansion (match-expansion
(use-package foo :requires (bar quux)) (use-package foo :requires (bar quux))
`(when (not (member nil (mapcar #'featurep '(bar quux)))) `(when (not (member nil (mapcar #'featurep '(bar quux))))
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:requires-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :requires bar) (use-package foo :requires bar)
@ -391,7 +409,7 @@
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil))))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:load-path () (ert-deftest use-package-test/:load-path-1 ()
(match-expansion (match-expansion
(use-package foo :load-path "bar") (use-package foo :load-path "bar")
`(progn `(progn
@ -401,8 +419,9 @@
#'string= #'string=
(expand-file-name (expand-file-name
"bar" user-emacs-directory))))) "bar" user-emacs-directory)))))
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:load-path-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :load-path "bar") (use-package foo :load-path "bar")
@ -417,8 +436,9 @@
(eval-when-compile (eval-when-compile
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:load-path-3 ()
(match-expansion (match-expansion
(use-package foo :load-path ("bar" "quux")) (use-package foo :load-path ("bar" "quux"))
`(progn `(progn
@ -434,8 +454,9 @@
#'string= #'string=
(expand-file-name (expand-file-name
"quux" user-emacs-directory))))) "quux" user-emacs-directory)))))
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:load-path-4 ()
(match-expansion (match-expansion
(use-package foo :load-path (lambda () (list "bar" "quux"))) (use-package foo :load-path (lambda () (list "bar" "quux")))
`(progn `(progn
@ -453,17 +474,19 @@
"quux" user-emacs-directory))))) "quux" user-emacs-directory)))))
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:no-require () (ert-deftest use-package-test/:no-require-1 ()
(match-expansion (match-expansion
(use-package foo :no-require t) (use-package foo :no-require t)
`nil) `nil))
(ert-deftest use-package-test/:no-require-2 ()
(match-expansion (match-expansion
(use-package foo :no-require t :config (config)) (use-package foo :no-require t :config (config))
`(progn `(progn
(config) (config)
t)) t)))
(ert-deftest use-package-test/:no-require-3 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :no-require t) (use-package foo :no-require t)
@ -483,7 +506,7 @@
(should-error (norm '("foo" . 99))) (should-error (norm '("foo" . 99)))
(should-error (norm '(99 . sym))))) (should-error (norm '(99 . sym)))))
(ert-deftest use-package-test/:bind () (ert-deftest use-package-test/:bind-1 ()
(match-expansion (match-expansion
(use-package foo :bind ("C-k" . key)) (use-package foo :bind ("C-k" . key))
`(progn `(progn
@ -492,7 +515,7 @@
(ignore (ignore
(bind-keys :package foo ("C-k" . key)))))) (bind-keys :package foo ("C-k" . key))))))
(ert-deftest use-package-test/:bind* () (ert-deftest use-package-test/:bind*-1 ()
(match-expansion (match-expansion
(use-package foo :bind* ("C-k" . key)) (use-package foo :bind* ("C-k" . key))
`(progn `(progn
@ -501,7 +524,7 @@
(ignore (ignore
(bind-keys* :package foo ("C-k" . key)))))) (bind-keys* :package foo ("C-k" . key))))))
(ert-deftest use-package-test/:bind-keymap () (ert-deftest use-package-test/:bind-keymap-1 ()
(match-expansion (match-expansion
(use-package foo :bind-keymap ("C-k" . key)) (use-package foo :bind-keymap ("C-k" . key))
`(ignore `(ignore
@ -510,7 +533,7 @@
(interactive) (interactive)
(use-package-autoload-keymap 'key 'foo nil)))))) (use-package-autoload-keymap 'key 'foo nil))))))
(ert-deftest use-package-test/:bind-keymap* () (ert-deftest use-package-test/:bind-keymap*-1 ()
(match-expansion (match-expansion
(use-package foo :bind-keymap* ("C-k" . key)) (use-package foo :bind-keymap* ("C-k" . key))
`(ignore `(ignore
@ -519,14 +542,15 @@
(interactive) (interactive)
(use-package-autoload-keymap 'key 'foo t)))))) (use-package-autoload-keymap 'key 'foo t))))))
(ert-deftest use-package-test/:interpreter () (ert-deftest use-package-test/:interpreter-1 ()
(match-expansion (match-expansion
(use-package foo :interpreter "interp") (use-package foo :interpreter "interp")
`(progn `(progn
(add-to-list 'interpreter-mode-alist '("interp" . foo)) (add-to-list 'interpreter-mode-alist '("interp" . foo))
(unless (fboundp 'foo) (unless (fboundp 'foo)
(autoload #'foo "foo" nil t)))) (autoload #'foo "foo" nil t)))))
(ert-deftest use-package-test/:interpreter-2 ()
(match-expansion (match-expansion
(use-package foo :interpreter ("interp" . fun)) (use-package foo :interpreter ("interp" . fun))
`(progn `(progn
@ -549,14 +573,15 @@
(should (equal (norm '((".foo" . foo) (".bar" . bar))) (should (equal (norm '((".foo" . foo) (".bar" . bar)))
'((".foo" . foo) (".bar" . bar)))))) '((".foo" . foo) (".bar" . bar))))))
(ert-deftest use-package-test/:mode () (ert-deftest use-package-test/:mode-1 ()
(match-expansion (match-expansion
(use-package foo :mode "interp") (use-package foo :mode "interp")
`(progn `(progn
(add-to-list 'auto-mode-alist '("interp" . foo)) (add-to-list 'auto-mode-alist '("interp" . foo))
(unless (fboundp 'foo) (unless (fboundp 'foo)
(autoload #'foo "foo" nil t)))) (autoload #'foo "foo" nil t)))))
(ert-deftest use-package-test/:mode-2 ()
(match-expansion (match-expansion
(use-package foo :mode ("interp" . fun)) (use-package foo :mode ("interp" . fun))
`(progn `(progn
@ -564,14 +589,15 @@
(unless (fboundp 'fun) (unless (fboundp 'fun)
(autoload #'fun "foo" nil t))))) (autoload #'fun "foo" nil t)))))
(ert-deftest use-package-test/:magic () (ert-deftest use-package-test/:magic-1 ()
(match-expansion (match-expansion
(use-package foo :magic "interp") (use-package foo :magic "interp")
`(progn `(progn
(add-to-list 'magic-mode-alist '("interp" . foo)) (add-to-list 'magic-mode-alist '("interp" . foo))
(unless (fboundp 'foo) (unless (fboundp 'foo)
(autoload #'foo "foo" nil t)))) (autoload #'foo "foo" nil t)))))
(ert-deftest use-package-test/:magic-2 ()
(match-expansion (match-expansion
(use-package foo :magic ("interp" . fun)) (use-package foo :magic ("interp" . fun))
`(progn `(progn
@ -579,14 +605,15 @@
(unless (fboundp 'fun) (unless (fboundp 'fun)
(autoload #'fun "foo" nil t))))) (autoload #'fun "foo" nil t)))))
(ert-deftest use-package-test/:magic-fallback () (ert-deftest use-package-test/:magic-fallback-1 ()
(match-expansion (match-expansion
(use-package foo :magic-fallback "interp") (use-package foo :magic-fallback "interp")
`(progn `(progn
(add-to-list 'magic-fallback-mode-alist '("interp" . foo)) (add-to-list 'magic-fallback-mode-alist '("interp" . foo))
(unless (fboundp 'foo) (unless (fboundp 'foo)
(autoload #'foo "foo" nil t)))) (autoload #'foo "foo" nil t)))))
(ert-deftest use-package-test/:magic-fallback-2 ()
(match-expansion (match-expansion
(use-package foo :magic-fallback ("interp" . fun)) (use-package foo :magic-fallback ("interp" . fun))
`(progn `(progn
@ -594,20 +621,22 @@
(unless (fboundp 'fun) (unless (fboundp 'fun)
(autoload #'fun "foo" nil t))))) (autoload #'fun "foo" nil t)))))
(ert-deftest use-package-test/:commands () (ert-deftest use-package-test/:commands-1 ()
(match-expansion (match-expansion
(use-package foo :commands bar) (use-package foo :commands bar)
`(unless (fboundp 'bar) `(unless (fboundp 'bar)
(autoload #'bar "foo" nil t))) (autoload #'bar "foo" nil t))))
(ert-deftest use-package-test/:commands-2 ()
(match-expansion (match-expansion
(use-package foo :commands (bar quux)) (use-package foo :commands (bar quux))
`(progn `(progn
(unless (fboundp 'bar) (unless (fboundp 'bar)
(autoload #'bar "foo" nil t)) (autoload #'bar "foo" nil t))
(unless (fboundp 'quux) (unless (fboundp 'quux)
(autoload #'quux "foo" nil t)))) (autoload #'quux "foo" nil t)))))
(ert-deftest use-package-test/:commands-3 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :commands (bar quux)) (use-package foo :commands (bar quux))
@ -625,11 +654,12 @@
(eval-when-compile (eval-when-compile
(declare-function quux "foo")))))) (declare-function quux "foo"))))))
(ert-deftest use-package-test/:defines () (ert-deftest use-package-test/:defines-1 ()
(match-expansion (match-expansion
(use-package foo :defines bar) (use-package foo :defines bar)
`(require 'foo nil nil)) `(require 'foo nil nil)))
(ert-deftest use-package-test/:defines-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :defines bar) (use-package foo :defines bar)
@ -642,11 +672,12 @@
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil))))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:functions () (ert-deftest use-package-test/:functions-1 ()
(match-expansion (match-expansion
(use-package foo :functions bar) (use-package foo :functions bar)
`(require 'foo nil nil)) `(require 'foo nil nil)))
(ert-deftest use-package-test/:functions-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :functions bar) (use-package foo :functions bar)
@ -657,12 +688,14 @@
(with-demoted-errors (with-demoted-errors
"Cannot load foo: %S" nil "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:functions-3 ()
(match-expansion (match-expansion
(use-package foo :defer t :functions bar) (use-package foo :defer t :functions bar)
`nil) `nil))
(ert-deftest use-package-test/:functions-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :defer t :functions bar) (use-package foo :defer t :functions bar)
@ -670,8 +703,9 @@
(declare-function bar "foo") (declare-function bar "foo")
(eval-when-compile (eval-when-compile
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))))) (load "foo" nil t)))))))
(ert-deftest use-package-test/:functions-5 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :defer t :config (config) :functions bar) (use-package foo :defer t :config (config) :functions bar)
@ -687,11 +721,12 @@
(config) (config)
t)))))) t))))))
(ert-deftest use-package-test/:defer () (ert-deftest use-package-test/:defer-1 ()
(match-expansion (match-expansion
(use-package foo) (use-package foo)
`(require 'foo nil nil)) `(require 'foo nil nil)))
(ert-deftest use-package-test/:defer-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo) (use-package foo)
@ -700,12 +735,14 @@
(eval-when-compile (eval-when-compile
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:defer-3 ()
(match-expansion (match-expansion
(use-package foo :defer t) (use-package foo :defer t)
`nil) `nil))
(ert-deftest use-package-test/:defer-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :defer t) (use-package foo :defer t)
@ -734,7 +771,7 @@
(should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow))) (should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow)))
'(((bar1 bar2) . baz) ((quux1 quux2) . bow)))))) '(((bar1 bar2) . baz) ((quux1 quux2) . bow))))))
(ert-deftest use-package-test/:hook () (ert-deftest use-package-test/:hook-1 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(should (should
(equal (equal
@ -773,27 +810,28 @@
;; '((foo bar baz)))) ;; '((foo bar baz))))
)) ))
(ert-deftest use-package-test/:custom () (ert-deftest use-package-test/:custom-1 ()
(match-expansion (match-expansion
(use-package foo :custom (foo bar)) (use-package foo :custom (foo bar))
`(progn `(progn
(customize-set-variable 'foo bar "Customized with use-package foo") (customize-set-variable 'foo bar "Customized with use-package foo")
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:custom-face () (ert-deftest use-package-test/:custom-face-1 ()
(match-expansion (match-expansion
(use-package foo :custom-face (foo ((t (:background "#e4edfc"))))) (use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
`(progn `(progn
(custom-set-faces '(foo ((t (:background "#e4edfc"))))) (custom-set-faces '(foo ((t (:background "#e4edfc")))))
(require 'foo nil nil)))) (require 'foo nil nil))))
(ert-deftest use-package-test/:init () (ert-deftest use-package-test/:init-1 ()
(match-expansion (match-expansion
(use-package foo :init (init)) (use-package foo :init (init))
`(progn `(progn
(init) (init)
(require 'foo nil nil))) (require 'foo nil nil))))
(ert-deftest use-package-test/:init-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :init (init)) (use-package foo :init (init))
@ -805,12 +843,13 @@
(init) (init)
(require 'foo nil nil))))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:after () (ert-deftest use-package-test/:after-1 ()
(match-expansion (match-expansion
(use-package foo :after bar) (use-package foo :after bar)
`(eval-after-load 'bar `(eval-after-load 'bar
'(require 'foo nil nil))) '(require 'foo nil nil))))
(ert-deftest use-package-test/:after-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :after bar) (use-package foo :after bar)
@ -820,20 +859,23 @@
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(eval-after-load 'bar (eval-after-load 'bar
'(require 'foo nil nil))))) '(require 'foo nil nil))))))
(ert-deftest use-package-test/:after-3 ()
(match-expansion (match-expansion
(use-package foo :after (bar quux)) (use-package foo :after (bar quux))
`(eval-after-load 'quux `(eval-after-load 'quux
'(eval-after-load 'bar '(eval-after-load 'bar
'(require 'foo nil nil)))) '(require 'foo nil nil)))))
(ert-deftest use-package-test/:after-4 ()
(match-expansion (match-expansion
(use-package foo :after (:all bar quux)) (use-package foo :after (:all bar quux))
`(eval-after-load 'quux `(eval-after-load 'quux
'(eval-after-load 'bar '(eval-after-load 'bar
'(require 'foo nil nil)))) '(require 'foo nil nil)))))
(ert-deftest use-package-test/:after-5 ()
(match-expansion (match-expansion
(use-package foo :after (:any bar quux)) (use-package foo :after (:any bar quux))
`(lexical-let ,_ `(lexical-let ,_
@ -842,8 +884,9 @@
(eval-after-load 'bar (eval-after-load 'bar
`(funcall ,_)) `(funcall ,_))
(eval-after-load 'quux (eval-after-load 'quux
`(funcall ,_)))))) `(funcall ,_)))))))
(ert-deftest use-package-test/:after-6 ()
(match-expansion (match-expansion
(use-package foo :after (:all (:any bar quux) bow)) (use-package foo :after (:all (:any bar quux) bow))
`(lexical-let ,_ `(lexical-let ,_
@ -853,8 +896,9 @@
(eval-after-load 'bar (eval-after-load 'bar
`(funcall ,_)) `(funcall ,_))
(eval-after-load 'quux (eval-after-load 'quux
`(funcall ,_))))))) `(funcall ,_))))))))
(ert-deftest use-package-test/:after-7 ()
(match-expansion (match-expansion
(use-package foo :after (:any (:all bar quux) bow)) (use-package foo :after (:any (:all bar quux) bow))
`(lexical-let ,_ `(lexical-let ,_
@ -864,8 +908,9 @@
'(eval-after-load 'bar '(eval-after-load 'bar
`(funcall ,_))) `(funcall ,_)))
(eval-after-load 'bow (eval-after-load 'bow
`(funcall ,_)))))) `(funcall ,_)))))))
(ert-deftest use-package-test/:after-8 ()
(match-expansion (match-expansion
(use-package foo :after (:all (:any bar quux) (:any bow baz))) (use-package foo :after (:all (:any bar quux) (:any bow baz)))
`(lexical-let ,_ `(lexical-let ,_
@ -882,8 +927,9 @@
(eval-after-load 'bar (eval-after-load 'bar
`(funcall ,_)) `(funcall ,_))
(eval-after-load 'quux (eval-after-load 'quux
`(funcall ,_)))))))) `(funcall ,_)))))))))
(ert-deftest use-package-test/:after-9 ()
(match-expansion (match-expansion
(use-package foo :after (:any (:all bar quux) (:all bow baz))) (use-package foo :after (:any (:all bar quux) (:all bow baz)))
`(lexical-let ,_ `(lexical-let ,_
@ -894,8 +940,9 @@
`(funcall ,_))) `(funcall ,_)))
(eval-after-load 'baz (eval-after-load 'baz
'(eval-after-load 'bow '(eval-after-load 'bow
`(funcall ,_))))))) `(funcall ,_))))))))
(ert-deftest use-package-test/:after-10 ()
(match-expansion (match-expansion
(use-package foo :after (:any (:all bar quux) (:any bow baz))) (use-package foo :after (:any (:all bar quux) (:any bow baz)))
`(lexical-let ,_ `(lexical-let ,_
@ -910,11 +957,12 @@
(eval-after-load 'baz (eval-after-load 'baz
`(funcall ,_)))))))) `(funcall ,_))))))))
(ert-deftest use-package-test/:demand () (ert-deftest use-package-test/:demand-1 ()
(match-expansion (match-expansion
(use-package foo :demand t) (use-package foo :demand t)
`(require 'foo nil nil)) `(require 'foo nil nil)))
(ert-deftest use-package-test/:demand-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :demand t) (use-package foo :demand t)
@ -923,15 +971,17 @@
(eval-when-compile (eval-when-compile
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil)))) (require 'foo nil nil)))))
(ert-deftest use-package-test/:demand-3 ()
(match-expansion (match-expansion
(use-package foo :demand t :config (config)) (use-package foo :demand t :config (config))
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(config) (config)
t)) t)))
(ert-deftest use-package-test/:demand-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :demand t :config (config)) (use-package foo :demand t :config (config))
@ -942,14 +992,16 @@
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil) (require 'foo nil nil)
(config) (config)
t))) t))))
(ert-deftest use-package-test/:demand-5 ()
;; #529 - :demand should not override an explicit use of :after ;; #529 - :demand should not override an explicit use of :after
(match-expansion (match-expansion
(use-package foo :demand t :after bar) (use-package foo :demand t :after bar)
`(eval-after-load 'bar `(eval-after-load 'bar
'(require 'foo nil nil))) '(require 'foo nil nil))))
(ert-deftest use-package-test/:demand-6 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :demand t :after bar) (use-package foo :demand t :after bar)
@ -959,8 +1011,9 @@
(with-demoted-errors "Cannot load foo: %S" nil (with-demoted-errors "Cannot load foo: %S" nil
(load "foo" nil t)))) (load "foo" nil t))))
(eval-after-load 'bar (eval-after-load 'bar
'(require 'foo nil nil))))) '(require 'foo nil nil))))))
(ert-deftest use-package-test/:demand-7 ()
(match-expansion (match-expansion
(use-package counsel (use-package counsel
:load-path "site-lisp/swiper" :load-path "site-lisp/swiper"
@ -994,14 +1047,15 @@
("C-*" . counsel-org-agenda-headlines) ("C-*" . counsel-org-agenda-headlines)
("M-x" . counsel-M-x)))))))) ("M-x" . counsel-M-x))))))))
(ert-deftest use-package-test/:config () (ert-deftest use-package-test/:config-1 ()
(match-expansion (match-expansion
(use-package foo :config (config)) (use-package foo :config (config))
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(config) (config)
t)) t)))
(ert-deftest use-package-test/:config-2 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :config (config)) (use-package foo :config (config))
@ -1012,15 +1066,17 @@
(load "foo" nil t)))) (load "foo" nil t))))
(require 'foo nil nil) (require 'foo nil nil)
(config) (config)
t))) t))))
(ert-deftest use-package-test/:config-3 ()
(match-expansion (match-expansion
(use-package foo :defer t :config (config)) (use-package foo :defer t :config (config))
`(eval-after-load 'foo `(eval-after-load 'foo
'(progn '(progn
(config) (config)
t))) t))))
(ert-deftest use-package-test/:config-4 ()
(let ((byte-compile-current-file t)) (let ((byte-compile-current-file t))
(match-expansion (match-expansion
(use-package foo :defer t :config (config)) (use-package foo :defer t :config (config))
@ -1046,29 +1102,31 @@
(should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar")) (should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
'((foo . "bar"))))) '((foo . "bar")))))
(ert-deftest use-package-test/:diminish () (ert-deftest use-package-test/:diminish-1 ()
(match-expansion (match-expansion
(use-package foo :diminish nil) (use-package foo :diminish nil)
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'diminish) (if (fboundp 'diminish)
(diminish 'foo-mode)))) (diminish 'foo-mode)))))
(ert-deftest use-package-test/:diminish-2 ()
(match-expansion (match-expansion
(use-package foo :diminish bar) (use-package foo :diminish bar)
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'diminish) (if (fboundp 'diminish)
(diminish 'bar)))) (diminish 'bar)))))
(ert-deftest use-package-test/:diminish-3 ()
(match-expansion (match-expansion
(use-package foo :diminish "bar") (use-package foo :diminish "bar")
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'diminish) (if (fboundp 'diminish)
(diminish 'foo-mode "bar")))) (diminish 'foo-mode "bar")))))
(ert-deftest use-package-test/:diminish-4 ()
(match-expansion (match-expansion
(use-package foo :diminish (foo . "bar")) (use-package foo :diminish (foo . "bar"))
`(progn `(progn
@ -1093,44 +1151,49 @@
`((a-mode nil foo) (b-mode " b" foo)))) `((a-mode nil foo) (b-mode " b" foo))))
(should-error (use-package-normalize/:delight 'foo :delight '((:eval 1))))) (should-error (use-package-normalize/:delight 'foo :delight '((:eval 1)))))
(ert-deftest use-package-test/:delight () (ert-deftest use-package-test/:delight-1 ()
(match-expansion (match-expansion
(use-package foo :delight) (use-package foo :delight)
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'delight) (if (fboundp 'delight)
(delight '((foo-mode nil foo)))))) (delight '((foo-mode nil foo)))))))
(ert-deftest use-package-test/:delight-2 ()
(should-error (should-error
(match-expansion (match-expansion
(use-package foo :delight nil) (use-package foo :delight nil)
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'diminish) (if (fboundp 'diminish)
(diminish 'foo-mode))))) (diminish 'foo-mode))))))
(ert-deftest use-package-test/:delight-3 ()
(match-expansion (match-expansion
(use-package foo :delight bar) (use-package foo :delight bar)
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'delight) (if (fboundp 'delight)
(delight '((bar nil foo)))))) (delight '((bar nil foo)))))))
(ert-deftest use-package-test/:delight-4 ()
(match-expansion (match-expansion
(use-package foo :delight "bar") (use-package foo :delight "bar")
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'delight) (if (fboundp 'delight)
(delight '((foo-mode "bar" foo)))))) (delight '((foo-mode "bar" foo)))))))
(ert-deftest use-package-test/:delight-5 ()
(should-error (should-error
(match-expansion (match-expansion
(use-package foo :delight (foo . "bar")) (use-package foo :delight (foo . "bar"))
`(progn `(progn
(require 'foo nil nil) (require 'foo nil nil)
(if (fboundp 'diminish) (if (fboundp 'diminish)
(diminish 'foo "bar"))))) (diminish 'foo "bar"))))))
(ert-deftest use-package-test/:delight-6 ()
(match-expansion (match-expansion
(use-package foo :delight (foo "bar")) (use-package foo :delight (foo "bar"))
`(progn `(progn