diff options
| author | John Wiegley | 2017-12-03 03:07:30 -0800 |
|---|---|---|
| committer | John Wiegley | 2017-12-03 03:09:26 -0800 |
| commit | 9ab797cccdcb8bd583c0e3148e1aeb251bf05fec (patch) | |
| tree | 3e927a738cd483799c5eb3c49f5a8fb0f8dc2e78 /test | |
| parent | a9429350d53d4b408600e1b43542e09aa9dc503d (diff) | |
| download | emacs-9ab797cccdcb8bd583c0e3148e1aeb251bf05fec.tar.gz emacs-9ab797cccdcb8bd583c0e3148e1aeb251bf05fec.zip | |
A great deal of internal reorganization and simplification
All handlers now address their own domain of work; :after has become safer;
keyword normalization is multi-stage process; setting use-package-verbose to
`debug' produces useful output in the *use-package* buffer in the case of load
time errors; use-package errors (even internal) won't stop Emacs from
starting (though a serious internal bug that errors out every use-package form
may stop anything from being configured!); and more.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/use-package/use-package-tests.el | 420 |
1 files changed, 220 insertions, 200 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 7bc2a486b79..5cf7a342b36 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el | |||
| @@ -26,23 +26,36 @@ | |||
| 26 | (require 'use-package) | 26 | (require 'use-package) |
| 27 | 27 | ||
| 28 | (setq use-package-always-ensure nil | 28 | (setq use-package-always-ensure nil |
| 29 | use-package-verbose nil | 29 | use-package-verbose 'errors |
| 30 | use-package-expand-minimally t | 30 | use-package-expand-minimally t |
| 31 | max-lisp-eval-depth 8000) | 31 | max-lisp-eval-depth 8000 |
| 32 | 32 | max-specpdl-size 8000) | |
| 33 | ;; (let ((byte-compile-current-file nil)) (expand-minimally ())) | ||
| 34 | (fset 'insert-expansion | ||
| 35 | [?\C-\M- ?\M-w ?\M-: ?\M-p ?\C-e ?\C-b ?\C-b ?\C-\M-b ?\C-y ?\C-\M-k return ?\C-\M- ?\M-w C-return ?\C-z ?\C-n ?\C-f ?\C-y ?\C-\M-k]) | ||
| 36 | 33 | ||
| 37 | (defmacro expand-minimally (form) | 34 | (defmacro expand-minimally (form) |
| 38 | `(let ((use-package-verbose nil) | 35 | `(let ((use-package-verbose 'errors) |
| 39 | (use-package-expand-minimally t)) | 36 | (use-package-expand-minimally t)) |
| 40 | (macroexpand ',form))) | 37 | (macroexpand-1 ',form))) |
| 41 | 38 | ||
| 42 | (defmacro match-expansion (form &rest value) | 39 | (defmacro match-expansion (form &rest value) |
| 43 | `(should (pcase (expand-minimally ,form) | 40 | `(should (pcase (expand-minimally ,form) |
| 44 | ,@(mapcar #'(lambda (x) (list x t)) value)))) | 41 | ,@(mapcar #'(lambda (x) (list x t)) value)))) |
| 45 | 42 | ||
| 43 | (defun fix-expansion () | ||
| 44 | (interactive) | ||
| 45 | (save-excursion | ||
| 46 | (unless (looking-at "(match-expansion") | ||
| 47 | (backward-up-list)) | ||
| 48 | (when (looking-at "(match-expansion") | ||
| 49 | (search-forward "(use-package") | ||
| 50 | (goto-char (match-beginning 0)) | ||
| 51 | (let ((decl (read (current-buffer)))) | ||
| 52 | (kill-sexp) | ||
| 53 | (let ((use-package-verbose 'errors) | ||
| 54 | (use-package-expand-minimally t)) | ||
| 55 | (insert ?\n ?\` (pp-to-string (macroexpand-1 decl)))))))) | ||
| 56 | |||
| 57 | (bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map) | ||
| 58 | |||
| 46 | (eval-when-compile | 59 | (eval-when-compile |
| 47 | (defun plist-delete (plist property) | 60 | (defun plist-delete (plist property) |
| 48 | "Delete PROPERTY from PLIST" | 61 | "Delete PROPERTY from PLIST" |
| @@ -87,11 +100,6 @@ | |||
| 87 | (ert-deftest use-package-test/:disabled () | 100 | (ert-deftest use-package-test/:disabled () |
| 88 | (match-expansion | 101 | (match-expansion |
| 89 | (use-package foo :disabled t) | 102 | (use-package foo :disabled t) |
| 90 | `()) | ||
| 91 | |||
| 92 | (match-expansion | ||
| 93 | ;; jww (2017-11-30): Should :disabled ignore its argument? | ||
| 94 | (use-package foo :disabled nil) | ||
| 95 | `())) | 103 | `())) |
| 96 | 104 | ||
| 97 | (ert-deftest use-package-test/:preface () | 105 | (ert-deftest use-package-test/:preface () |
| @@ -176,8 +184,7 @@ | |||
| 176 | (ert-deftest use-package-test/:defer-install () | 184 | (ert-deftest use-package-test/:defer-install () |
| 177 | (match-expansion | 185 | (match-expansion |
| 178 | (use-package foo :defer-install t) | 186 | (use-package foo :defer-install t) |
| 179 | `(progn | 187 | `(require 'foo nil nil))) |
| 180 | (require 'foo nil nil)))) | ||
| 181 | 188 | ||
| 182 | (ert-deftest use-package-test-normalize/:ensure () | 189 | (ert-deftest use-package-test-normalize/:ensure () |
| 183 | (flet ((norm (&rest args) | 190 | (flet ((norm (&rest args) |
| @@ -230,7 +237,6 @@ | |||
| 230 | (match-expansion | 237 | (match-expansion |
| 231 | (use-package foo :load-path "foo") | 238 | (use-package foo :load-path "foo") |
| 232 | `(progn | 239 | `(progn |
| 233 | (use-package-ensure-elpa 'foo 'nil 'nil) | ||
| 234 | (eval-and-compile | 240 | (eval-and-compile |
| 235 | (add-to-list 'load-path ,(pred stringp))) | 241 | (add-to-list 'load-path ,(pred stringp))) |
| 236 | (require 'foo nil nil)))) | 242 | (require 'foo nil nil)))) |
| @@ -283,77 +289,82 @@ | |||
| 283 | (ert-deftest use-package-test/:if () | 289 | (ert-deftest use-package-test/:if () |
| 284 | (match-expansion | 290 | (match-expansion |
| 285 | (use-package foo :if t) | 291 | (use-package foo :if t) |
| 286 | `(progn | 292 | `(when t |
| 287 | (when (symbol-value 't) | 293 | (require 'foo nil nil))) |
| 288 | (require 'foo nil nil)))) | ||
| 289 | 294 | ||
| 290 | (match-expansion | 295 | (match-expansion |
| 291 | (use-package foo :if (and t t)) | 296 | (use-package foo :if (and t t)) |
| 292 | `(progn | 297 | `(when (and t t) |
| 293 | (when (and t t) | 298 | (require 'foo nil nil))) |
| 294 | (require 'foo nil nil)))) | ||
| 295 | 299 | ||
| 296 | (match-expansion | 300 | (match-expansion |
| 297 | (use-package foo :if nil) | 301 | (use-package foo :if nil) |
| 298 | `(progn | 302 | `(when nil |
| 299 | (when nil | 303 | (require 'foo nil nil)))) |
| 300 | (require 'foo nil nil))))) | ||
| 301 | 304 | ||
| 302 | (ert-deftest use-package-test/:when () | 305 | (ert-deftest use-package-test/:when () |
| 303 | (match-expansion | 306 | (match-expansion |
| 304 | (use-package foo :when t) | 307 | (use-package foo :when t) |
| 305 | `(progn | 308 | `(when t |
| 306 | (when (symbol-value 't) | 309 | (require 'foo nil nil))) |
| 307 | (require 'foo nil nil)))) | ||
| 308 | 310 | ||
| 309 | (match-expansion | 311 | (match-expansion |
| 310 | (use-package foo :when (and t t)) | 312 | (use-package foo :when (and t t)) |
| 311 | `(progn | 313 | `(when (and t t) |
| 312 | (when (and t t) | 314 | (require 'foo nil nil))) |
| 313 | (require 'foo nil nil)))) | ||
| 314 | 315 | ||
| 315 | (match-expansion | 316 | (match-expansion |
| 316 | (use-package foo :when nil) | 317 | (use-package foo :when nil) |
| 317 | `(progn | 318 | `(when nil |
| 318 | (when nil | 319 | (require 'foo nil nil)))) |
| 319 | (require 'foo nil nil))))) | ||
| 320 | 320 | ||
| 321 | (ert-deftest use-package-test/:unless () | 321 | (ert-deftest use-package-test/:unless () |
| 322 | (match-expansion | 322 | (match-expansion |
| 323 | (use-package foo :unless t) | 323 | (use-package foo :unless t) |
| 324 | `(progn | 324 | `(when (not t) |
| 325 | (unless (symbol-value 't) | 325 | (require 'foo nil nil))) |
| 326 | (require 'foo nil nil)))) | ||
| 327 | 326 | ||
| 328 | (match-expansion | 327 | (match-expansion |
| 329 | (use-package foo :unless (and t t)) | 328 | (use-package foo :unless (and t t)) |
| 330 | `(progn | 329 | `(when (not (and t t)) |
| 331 | (unless (and t t) | 330 | (require 'foo nil nil))) |
| 332 | (require 'foo nil nil)))) | ||
| 333 | 331 | ||
| 334 | (match-expansion | 332 | (match-expansion |
| 335 | (use-package foo :unless nil) | 333 | (use-package foo :unless nil) |
| 336 | `(progn | 334 | `(unless nil |
| 337 | (unless nil | 335 | (require 'foo nil nil)))) |
| 338 | (require 'foo nil nil))))) | ||
| 339 | 336 | ||
| 340 | (ert-deftest use-package-test/:requires () | 337 | (ert-deftest use-package-test/:requires () |
| 341 | (match-expansion | 338 | (match-expansion |
| 342 | (use-package foo :requires bar) | 339 | (use-package foo :requires bar) |
| 343 | `(progn | 340 | `(when (featurep 'bar) |
| 344 | (when (not (member nil (mapcar #'featurep '(bar)))) | 341 | (require 'foo nil nil))) |
| 342 | |||
| 343 | (let ((byte-compile-current-file t)) | ||
| 344 | (match-expansion | ||
| 345 | (use-package foo :requires bar) | ||
| 346 | `(when (featurep 'bar) | ||
| 347 | (eval-and-compile | ||
| 348 | (eval-when-compile | ||
| 349 | (with-demoted-errors | ||
| 350 | "Cannot load foo: %S" nil | ||
| 351 | (load "foo" nil t)))) | ||
| 345 | (require 'foo nil nil)))) | 352 | (require 'foo nil nil)))) |
| 346 | 353 | ||
| 354 | (match-expansion | ||
| 355 | (use-package foo :requires (bar quux)) | ||
| 356 | `(when (not (member nil (mapcar #'featurep '(bar quux)))) | ||
| 357 | (require 'foo nil nil))) | ||
| 358 | |||
| 347 | (let ((byte-compile-current-file t)) | 359 | (let ((byte-compile-current-file t)) |
| 348 | (match-expansion | 360 | (match-expansion |
| 349 | (use-package foo :requires bar) | 361 | (use-package foo :requires bar) |
| 350 | `(progn | 362 | `(when (featurep 'bar) |
| 351 | (when (not (member nil (mapcar #'featurep '(bar)))) | 363 | (eval-and-compile |
| 352 | (eval-and-compile | 364 | (eval-when-compile |
| 353 | (eval-when-compile | 365 | (with-demoted-errors "Cannot load foo: %S" nil |
| 354 | (with-demoted-errors "Cannot load foo: %S" nil | 366 | (load "foo" nil t)))) |
| 355 | (load "foo" nil t)))) | 367 | (require 'foo nil nil))))) |
| 356 | (require 'foo nil nil)))))) | ||
| 357 | 368 | ||
| 358 | (ert-deftest use-package-test/:load-path () | 369 | (ert-deftest use-package-test/:load-path () |
| 359 | (match-expansion | 370 | (match-expansion |
| @@ -420,7 +431,7 @@ | |||
| 420 | (ert-deftest use-package-test/:no-require () | 431 | (ert-deftest use-package-test/:no-require () |
| 421 | (match-expansion | 432 | (match-expansion |
| 422 | (use-package foo :no-require t) | 433 | (use-package foo :no-require t) |
| 423 | `(progn)) | 434 | `nil) |
| 424 | 435 | ||
| 425 | (match-expansion | 436 | (match-expansion |
| 426 | (use-package foo :no-require t :config (config)) | 437 | (use-package foo :no-require t :config (config)) |
| @@ -431,10 +442,9 @@ | |||
| 431 | (let ((byte-compile-current-file t)) | 442 | (let ((byte-compile-current-file t)) |
| 432 | (match-expansion | 443 | (match-expansion |
| 433 | (use-package foo :no-require t) | 444 | (use-package foo :no-require t) |
| 434 | `(progn | 445 | `(eval-and-compile |
| 435 | (eval-and-compile | 446 | (eval-when-compile |
| 436 | (eval-when-compile | 447 | (with-demoted-errors "Cannot load foo: %S" nil nil)))))) |
| 437 | (with-demoted-errors "Cannot load foo: %S" nil nil))))))) | ||
| 438 | 448 | ||
| 439 | (ert-deftest use-package-test-normalize/:bind () | 449 | (ert-deftest use-package-test-normalize/:bind () |
| 440 | (flet ((norm (&rest args) | 450 | (flet ((norm (&rest args) |
| @@ -469,41 +479,35 @@ | |||
| 469 | (ert-deftest use-package-test/:bind-keymap () | 479 | (ert-deftest use-package-test/:bind-keymap () |
| 470 | (match-expansion | 480 | (match-expansion |
| 471 | (use-package foo :bind-keymap ("C-k" . key)) | 481 | (use-package foo :bind-keymap ("C-k" . key)) |
| 472 | `(progn | 482 | `(ignore |
| 473 | (ignore | 483 | (bind-key "C-k" |
| 474 | (bind-key "C-k" | 484 | #'(lambda nil |
| 475 | #'(lambda () | 485 | (interactive) |
| 476 | (interactive) | 486 | (use-package-autoload-keymap 'key 'foo nil)))))) |
| 477 | (use-package-autoload-keymap 'key 'foo nil))))))) | ||
| 478 | 487 | ||
| 479 | (ert-deftest use-package-test/:bind-keymap* () | 488 | (ert-deftest use-package-test/:bind-keymap* () |
| 480 | (match-expansion | 489 | (match-expansion |
| 481 | (use-package foo :bind-keymap* ("C-k" . key)) | 490 | (use-package foo :bind-keymap* ("C-k" . key)) |
| 482 | `(progn | 491 | `(ignore |
| 483 | (ignore | 492 | (bind-key* "C-k" |
| 484 | (bind-key* "C-k" | 493 | #'(lambda () |
| 485 | #'(lambda () | 494 | (interactive) |
| 486 | (interactive) | 495 | (use-package-autoload-keymap 'key 'foo t)))))) |
| 487 | (use-package-autoload-keymap 'key 'foo t))))))) | ||
| 488 | 496 | ||
| 489 | (ert-deftest use-package-test/:interpreter () | 497 | (ert-deftest use-package-test/:interpreter () |
| 490 | (match-expansion | 498 | (match-expansion |
| 491 | (use-package foo :interpreter "interp") | 499 | (use-package foo :interpreter "interp") |
| 492 | `(progn | 500 | `(progn |
| 501 | (add-to-list 'interpreter-mode-alist '("interp" . foo)) | ||
| 493 | (unless (fboundp 'foo) | 502 | (unless (fboundp 'foo) |
| 494 | (autoload #'foo "foo" nil t)) | 503 | (autoload #'foo "foo" nil t)))) |
| 495 | (ignore | ||
| 496 | (add-to-list 'interpreter-mode-alist | ||
| 497 | '("interp" . foo))))) | ||
| 498 | 504 | ||
| 499 | (match-expansion | 505 | (match-expansion |
| 500 | (use-package foo :interpreter ("interp" . fun)) | 506 | (use-package foo :interpreter ("interp" . fun)) |
| 501 | `(progn | 507 | `(progn |
| 508 | (add-to-list 'interpreter-mode-alist '("interp" . fun)) | ||
| 502 | (unless (fboundp 'fun) | 509 | (unless (fboundp 'fun) |
| 503 | (autoload #'fun "foo" nil t)) | 510 | (autoload #'fun "foo" nil t))))) |
| 504 | (ignore | ||
| 505 | (add-to-list 'interpreter-mode-alist | ||
| 506 | '("interp" . fun)))))) | ||
| 507 | 511 | ||
| 508 | (ert-deftest use-package-test-normalize/:mode () | 512 | (ert-deftest use-package-test-normalize/:mode () |
| 509 | (flet ((norm (&rest args) | 513 | (flet ((norm (&rest args) |
| @@ -524,65 +528,52 @@ | |||
| 524 | (match-expansion | 528 | (match-expansion |
| 525 | (use-package foo :mode "interp") | 529 | (use-package foo :mode "interp") |
| 526 | `(progn | 530 | `(progn |
| 531 | (add-to-list 'auto-mode-alist '("interp" . foo)) | ||
| 527 | (unless (fboundp 'foo) | 532 | (unless (fboundp 'foo) |
| 528 | (autoload #'foo "foo" nil t)) | 533 | (autoload #'foo "foo" nil t)))) |
| 529 | (ignore | ||
| 530 | (add-to-list 'auto-mode-alist | ||
| 531 | '("interp" . foo))))) | ||
| 532 | 534 | ||
| 533 | (match-expansion | 535 | (match-expansion |
| 534 | (use-package foo :mode ("interp" . fun)) | 536 | (use-package foo :mode ("interp" . fun)) |
| 535 | `(progn | 537 | `(progn |
| 538 | (add-to-list 'auto-mode-alist '("interp" . fun)) | ||
| 536 | (unless (fboundp 'fun) | 539 | (unless (fboundp 'fun) |
| 537 | (autoload #'fun "foo" nil t)) | 540 | (autoload #'fun "foo" nil t))))) |
| 538 | (ignore | ||
| 539 | (add-to-list 'auto-mode-alist | ||
| 540 | '("interp" . fun)))))) | ||
| 541 | 541 | ||
| 542 | (ert-deftest use-package-test/:magic () | 542 | (ert-deftest use-package-test/:magic () |
| 543 | (match-expansion | 543 | (match-expansion |
| 544 | (use-package foo :magic "interp") | 544 | (use-package foo :magic "interp") |
| 545 | `(progn | 545 | `(progn |
| 546 | (add-to-list 'magic-mode-alist '("interp" . foo)) | ||
| 546 | (unless (fboundp 'foo) | 547 | (unless (fboundp 'foo) |
| 547 | (autoload #'foo "foo" nil t)) | 548 | (autoload #'foo "foo" nil t)))) |
| 548 | (ignore | ||
| 549 | (add-to-list 'magic-mode-alist | ||
| 550 | '("interp" . foo))))) | ||
| 551 | 549 | ||
| 552 | (match-expansion | 550 | (match-expansion |
| 553 | (use-package foo :magic ("interp" . fun)) | 551 | (use-package foo :magic ("interp" . fun)) |
| 554 | `(progn | 552 | `(progn |
| 553 | (add-to-list 'magic-mode-alist '("interp" . fun)) | ||
| 555 | (unless (fboundp 'fun) | 554 | (unless (fboundp 'fun) |
| 556 | (autoload #'fun "foo" nil t)) | 555 | (autoload #'fun "foo" nil t))))) |
| 557 | (ignore | ||
| 558 | (add-to-list 'magic-mode-alist | ||
| 559 | '("interp" . fun)))))) | ||
| 560 | 556 | ||
| 561 | (ert-deftest use-package-test/:magic-fallback () | 557 | (ert-deftest use-package-test/:magic-fallback () |
| 562 | (match-expansion | 558 | (match-expansion |
| 563 | (use-package foo :magic-fallback "interp") | 559 | (use-package foo :magic-fallback "interp") |
| 564 | `(progn | 560 | `(progn |
| 561 | (add-to-list 'magic-fallback-mode-alist '("interp" . foo)) | ||
| 565 | (unless (fboundp 'foo) | 562 | (unless (fboundp 'foo) |
| 566 | (autoload #'foo "foo" nil t)) | 563 | (autoload #'foo "foo" nil t)))) |
| 567 | (ignore | ||
| 568 | (add-to-list 'magic-fallback-mode-alist | ||
| 569 | '("interp" . foo))))) | ||
| 570 | 564 | ||
| 571 | (match-expansion | 565 | (match-expansion |
| 572 | (use-package foo :magic-fallback ("interp" . fun)) | 566 | (use-package foo :magic-fallback ("interp" . fun)) |
| 573 | `(progn | 567 | `(progn |
| 568 | (add-to-list 'magic-fallback-mode-alist '("interp" . fun)) | ||
| 574 | (unless (fboundp 'fun) | 569 | (unless (fboundp 'fun) |
| 575 | (autoload #'fun "foo" nil t)) | 570 | (autoload #'fun "foo" nil t))))) |
| 576 | (ignore | ||
| 577 | (add-to-list 'magic-fallback-mode-alist | ||
| 578 | '("interp" . fun)))))) | ||
| 579 | 571 | ||
| 580 | (ert-deftest use-package-test/:commands () | 572 | (ert-deftest use-package-test/:commands () |
| 581 | (match-expansion | 573 | (match-expansion |
| 582 | (use-package foo :commands bar) | 574 | (use-package foo :commands bar) |
| 583 | `(progn | 575 | `(unless (fboundp 'bar) |
| 584 | (unless (fboundp 'bar) | 576 | (autoload #'bar "foo" nil t))) |
| 585 | (autoload #'bar "foo" nil t)))) | ||
| 586 | 577 | ||
| 587 | (match-expansion | 578 | (match-expansion |
| 588 | (use-package foo :commands (bar quux)) | 579 | (use-package foo :commands (bar quux)) |
| @@ -612,8 +603,7 @@ | |||
| 612 | (ert-deftest use-package-test/:defines () | 603 | (ert-deftest use-package-test/:defines () |
| 613 | (match-expansion | 604 | (match-expansion |
| 614 | (use-package foo :defines bar) | 605 | (use-package foo :defines bar) |
| 615 | `(progn | 606 | `(require 'foo nil nil)) |
| 616 | (require 'foo nil nil))) | ||
| 617 | 607 | ||
| 618 | (let ((byte-compile-current-file t)) | 608 | (let ((byte-compile-current-file t)) |
| 619 | (match-expansion | 609 | (match-expansion |
| @@ -630,8 +620,7 @@ | |||
| 630 | (ert-deftest use-package-test/:functions () | 620 | (ert-deftest use-package-test/:functions () |
| 631 | (match-expansion | 621 | (match-expansion |
| 632 | (use-package foo :functions bar) | 622 | (use-package foo :functions bar) |
| 633 | `(progn | 623 | `(require 'foo nil nil)) |
| 634 | (require 'foo nil nil))) | ||
| 635 | 624 | ||
| 636 | (let ((byte-compile-current-file t)) | 625 | (let ((byte-compile-current-file t)) |
| 637 | (match-expansion | 626 | (match-expansion |
| @@ -647,17 +636,16 @@ | |||
| 647 | 636 | ||
| 648 | (match-expansion | 637 | (match-expansion |
| 649 | (use-package foo :defer t :functions bar) | 638 | (use-package foo :defer t :functions bar) |
| 650 | `(progn)) | 639 | `nil) |
| 651 | 640 | ||
| 652 | (let ((byte-compile-current-file t)) | 641 | (let ((byte-compile-current-file t)) |
| 653 | (match-expansion | 642 | (match-expansion |
| 654 | (use-package foo :defer t :functions bar) | 643 | (use-package foo :defer t :functions bar) |
| 655 | `(progn | 644 | `(eval-and-compile |
| 656 | (eval-and-compile | 645 | (declare-function bar "foo") |
| 657 | (declare-function bar "foo") | 646 | (eval-when-compile |
| 658 | (eval-when-compile | 647 | (with-demoted-errors "Cannot load foo: %S" nil |
| 659 | (with-demoted-errors "Cannot load foo: %S" nil | 648 | (load "foo" nil t)))))) |
| 660 | (load "foo" nil t))))))) | ||
| 661 | 649 | ||
| 662 | (let ((byte-compile-current-file t)) | 650 | (let ((byte-compile-current-file t)) |
| 663 | (match-expansion | 651 | (match-expansion |
| @@ -677,8 +665,7 @@ | |||
| 677 | (ert-deftest use-package-test/:defer () | 665 | (ert-deftest use-package-test/:defer () |
| 678 | (match-expansion | 666 | (match-expansion |
| 679 | (use-package foo) | 667 | (use-package foo) |
| 680 | `(progn | 668 | `(require 'foo nil nil)) |
| 681 | (require 'foo nil nil))) | ||
| 682 | 669 | ||
| 683 | (let ((byte-compile-current-file t)) | 670 | (let ((byte-compile-current-file t)) |
| 684 | (match-expansion | 671 | (match-expansion |
| @@ -692,16 +679,15 @@ | |||
| 692 | 679 | ||
| 693 | (match-expansion | 680 | (match-expansion |
| 694 | (use-package foo :defer t) | 681 | (use-package foo :defer t) |
| 695 | `(progn)) | 682 | `nil) |
| 696 | 683 | ||
| 697 | (let ((byte-compile-current-file t)) | 684 | (let ((byte-compile-current-file t)) |
| 698 | (match-expansion | 685 | (match-expansion |
| 699 | (use-package foo :defer t) | 686 | (use-package foo :defer t) |
| 700 | `(progn | 687 | `(eval-and-compile |
| 701 | (eval-and-compile | 688 | (eval-when-compile |
| 702 | (eval-when-compile | 689 | (with-demoted-errors "Cannot load foo: %S" nil |
| 703 | (with-demoted-errors "Cannot load foo: %S" nil | 690 | (load "foo" nil t))))))) |
| 704 | (load "foo" nil t)))))))) | ||
| 705 | 691 | ||
| 706 | (ert-deftest use-package-test-normalize/:hook () | 692 | (ert-deftest use-package-test-normalize/:hook () |
| 707 | (flet ((norm (&rest args) | 693 | (flet ((norm (&rest args) |
| @@ -726,7 +712,7 @@ | |||
| 726 | (ert-deftest use-package-test/:hook () | 712 | (ert-deftest use-package-test/:hook () |
| 727 | (let ((byte-compile-current-file t)) | 713 | (let ((byte-compile-current-file t)) |
| 728 | (should | 714 | (should |
| 729 | (equal ; pcase crashes | 715 | (equal |
| 730 | (expand-minimally | 716 | (expand-minimally |
| 731 | (use-package foo | 717 | (use-package foo |
| 732 | :bind (("C-a" . key)) | 718 | :bind (("C-a" . key)) |
| @@ -734,8 +720,10 @@ | |||
| 734 | '(progn | 720 | '(progn |
| 735 | (eval-and-compile | 721 | (eval-and-compile |
| 736 | (eval-when-compile | 722 | (eval-when-compile |
| 737 | (with-demoted-errors "Cannot load foo: %S" nil | 723 | (with-demoted-errors |
| 738 | (load "foo" nil t)))) | 724 | "Cannot load foo: %S" nil |
| 725 | (load "foo" nil t)))) | ||
| 726 | (add-hook 'hook-hook #'fun) | ||
| 739 | (unless (fboundp 'fun) | 727 | (unless (fboundp 'fun) |
| 740 | (autoload #'fun "foo" nil t)) | 728 | (autoload #'fun "foo" nil t)) |
| 741 | (eval-when-compile | 729 | (eval-when-compile |
| @@ -744,7 +732,6 @@ | |||
| 744 | (autoload #'key "foo" nil t)) | 732 | (autoload #'key "foo" nil t)) |
| 745 | (eval-when-compile | 733 | (eval-when-compile |
| 746 | (declare-function key "foo")) | 734 | (declare-function key "foo")) |
| 747 | (add-hook 'hook-hook #'fun) | ||
| 748 | (ignore | 735 | (ignore |
| 749 | (bind-keys :package foo ("C-a" . key)))))))) | 736 | (bind-keys :package foo ("C-a" . key)))))))) |
| 750 | 737 | ||
| @@ -796,9 +783,8 @@ | |||
| 796 | (ert-deftest use-package-test/:after () | 783 | (ert-deftest use-package-test/:after () |
| 797 | (match-expansion | 784 | (match-expansion |
| 798 | (use-package foo :after bar) | 785 | (use-package foo :after bar) |
| 799 | `(progn | 786 | `(eval-after-load 'bar |
| 800 | (eval-after-load 'bar | 787 | '(require 'foo nil nil))) |
| 801 | '(require 'foo nil nil)))) | ||
| 802 | 788 | ||
| 803 | (let ((byte-compile-current-file t)) | 789 | (let ((byte-compile-current-file t)) |
| 804 | (match-expansion | 790 | (match-expansion |
| @@ -813,93 +799,96 @@ | |||
| 813 | 799 | ||
| 814 | (match-expansion | 800 | (match-expansion |
| 815 | (use-package foo :after (bar quux)) | 801 | (use-package foo :after (bar quux)) |
| 816 | `(progn | 802 | `(eval-after-load 'quux |
| 817 | (eval-after-load 'quux | 803 | '(eval-after-load 'bar |
| 818 | '(eval-after-load 'bar | 804 | '(require 'foo nil nil)))) |
| 819 | '(require 'foo nil nil))))) | ||
| 820 | 805 | ||
| 821 | (match-expansion | 806 | (match-expansion |
| 822 | (use-package foo :after (:all bar quux)) | 807 | (use-package foo :after (:all bar quux)) |
| 823 | `(progn | 808 | `(eval-after-load 'quux |
| 824 | (eval-after-load 'quux | 809 | '(eval-after-load 'bar |
| 825 | '(eval-after-load 'bar | 810 | '(require 'foo nil nil)))) |
| 826 | '(require 'foo nil nil))))) | ||
| 827 | 811 | ||
| 828 | (match-expansion | 812 | (match-expansion |
| 829 | (use-package foo :after (:any bar quux)) | 813 | (use-package foo :after (:any bar quux)) |
| 830 | `(progn | 814 | `(lexical-let ,_ |
| 831 | (progn | 815 | (lexical-let ,_ |
| 832 | (eval-after-load 'bar | 816 | (progn |
| 833 | '(require 'foo nil nil)) | 817 | (eval-after-load 'bar |
| 834 | (eval-after-load 'quux | 818 | `(funcall ,_)) |
| 835 | '(require 'foo nil nil))))) | 819 | (eval-after-load 'quux |
| 820 | `(funcall ,_)))))) | ||
| 836 | 821 | ||
| 837 | (match-expansion | 822 | (match-expansion |
| 838 | (use-package foo :after (:all (:any bar quux) bow)) | 823 | (use-package foo :after (:all (:any bar quux) bow)) |
| 839 | `(progn | 824 | `(lexical-let ,_ |
| 840 | (eval-after-load 'bow | 825 | (lexical-let ,_ |
| 841 | '(progn | 826 | (eval-after-load 'bow |
| 842 | (eval-after-load 'bar | 827 | '(progn |
| 843 | '(require 'foo nil nil)) | 828 | (eval-after-load 'bar |
| 844 | (eval-after-load 'quux | 829 | `(funcall ,_)) |
| 845 | '(require 'foo nil nil)))))) | 830 | (eval-after-load 'quux |
| 831 | `(funcall ,_))))))) | ||
| 846 | 832 | ||
| 847 | (match-expansion | 833 | (match-expansion |
| 848 | (use-package foo :after (:any (:all bar quux) bow)) | 834 | (use-package foo :after (:any (:all bar quux) bow)) |
| 849 | `(progn | 835 | `(lexical-let ,_ |
| 850 | (progn | 836 | (lexical-let ,_ |
| 851 | (eval-after-load 'quux | 837 | (progn |
| 852 | '(eval-after-load 'bar | 838 | (eval-after-load 'quux |
| 853 | '(require 'foo nil nil))) | 839 | '(eval-after-load 'bar |
| 854 | (eval-after-load 'bow | 840 | `(funcall ,_))) |
| 855 | '(require 'foo nil nil))))) | 841 | (eval-after-load 'bow |
| 842 | `(funcall ,_)))))) | ||
| 856 | 843 | ||
| 857 | (match-expansion | 844 | (match-expansion |
| 858 | (use-package foo :after (:all (:any bar quux) (:any bow baz))) | 845 | (use-package foo :after (:all (:any bar quux) (:any bow baz))) |
| 859 | `(progn | 846 | `(lexical-let ,_ |
| 860 | (progn | 847 | (lexical-let ,_ |
| 861 | (eval-after-load 'bow | 848 | (progn |
| 862 | '(progn | 849 | (eval-after-load 'bow |
| 863 | (eval-after-load 'bar | 850 | '(progn |
| 864 | '(require 'foo nil nil)) | 851 | (eval-after-load 'bar |
| 865 | (eval-after-load 'quux | 852 | `(funcall ,_)) |
| 866 | '(require 'foo nil nil)))) | 853 | (eval-after-load 'quux |
| 867 | (eval-after-load 'baz | 854 | `(funcall ,_)))) |
| 868 | '(progn | 855 | (eval-after-load 'baz |
| 869 | (eval-after-load 'bar | 856 | '(progn |
| 870 | '(require 'foo nil nil)) | 857 | (eval-after-load 'bar |
| 871 | (eval-after-load 'quux | 858 | `(funcall ,_)) |
| 872 | '(require 'foo nil nil))))))) | 859 | (eval-after-load 'quux |
| 860 | `(funcall ,_)))))))) | ||
| 873 | 861 | ||
| 874 | (match-expansion | 862 | (match-expansion |
| 875 | (use-package foo :after (:any (:all bar quux) (:all bow baz))) | 863 | (use-package foo :after (:any (:all bar quux) (:all bow baz))) |
| 876 | `(progn | 864 | `(lexical-let ,_ |
| 877 | (progn | 865 | (lexical-let ,_ |
| 878 | (eval-after-load 'quux | 866 | (progn |
| 879 | '(eval-after-load 'bar | 867 | (eval-after-load 'quux |
| 880 | '(require 'foo nil nil))) | 868 | '(eval-after-load 'bar |
| 881 | (eval-after-load 'baz | 869 | `(funcall ,_))) |
| 882 | '(eval-after-load 'bow | 870 | (eval-after-load 'baz |
| 883 | '(require 'foo nil nil)))))) | 871 | '(eval-after-load 'bow |
| 872 | `(funcall ,_))))))) | ||
| 884 | 873 | ||
| 885 | (match-expansion | 874 | (match-expansion |
| 886 | (use-package foo :after (:any (:all bar quux) (:any bow baz))) | 875 | (use-package foo :after (:any (:all bar quux) (:any bow baz))) |
| 887 | `(progn | 876 | `(lexical-let ,_ |
| 888 | (progn | 877 | (lexical-let ,_ |
| 889 | (eval-after-load 'quux | ||
| 890 | '(eval-after-load 'bar | ||
| 891 | '(require 'foo nil nil))) | ||
| 892 | (progn | 878 | (progn |
| 893 | (eval-after-load 'bow | 879 | (eval-after-load 'quux |
| 894 | '(require 'foo nil nil)) | 880 | '(eval-after-load 'bar |
| 895 | (eval-after-load 'baz | 881 | `(funcall ,_))) |
| 896 | '(require 'foo nil nil))))))) | 882 | (progn |
| 883 | (eval-after-load 'bow | ||
| 884 | `(funcall ,use-package--next142993)) | ||
| 885 | (eval-after-load 'baz | ||
| 886 | `(funcall ,_)))))))) | ||
| 897 | 887 | ||
| 898 | (ert-deftest use-package-test/:demand () | 888 | (ert-deftest use-package-test/:demand () |
| 899 | (match-expansion | 889 | (match-expansion |
| 900 | (use-package foo :demand t) | 890 | (use-package foo :demand t) |
| 901 | `(progn | 891 | `(require 'foo nil nil)) |
| 902 | (require 'foo nil nil))) | ||
| 903 | 892 | ||
| 904 | (let ((byte-compile-current-file t)) | 893 | (let ((byte-compile-current-file t)) |
| 905 | (match-expansion | 894 | (match-expansion |
| @@ -933,9 +922,8 @@ | |||
| 933 | ;; #529 - :demand should not override an explicit use of :after | 922 | ;; #529 - :demand should not override an explicit use of :after |
| 934 | (match-expansion | 923 | (match-expansion |
| 935 | (use-package foo :demand t :after bar) | 924 | (use-package foo :demand t :after bar) |
| 936 | `(progn | 925 | `(eval-after-load 'bar |
| 937 | (eval-after-load 'bar | 926 | '(require 'foo nil nil))) |
| 938 | '(require 'foo nil nil)))) | ||
| 939 | 927 | ||
| 940 | (let ((byte-compile-current-file t)) | 928 | (let ((byte-compile-current-file t)) |
| 941 | (match-expansion | 929 | (match-expansion |
| @@ -946,7 +934,40 @@ | |||
| 946 | (with-demoted-errors "Cannot load foo: %S" nil | 934 | (with-demoted-errors "Cannot load foo: %S" nil |
| 947 | (load "foo" nil t)))) | 935 | (load "foo" nil t)))) |
| 948 | (eval-after-load 'bar | 936 | (eval-after-load 'bar |
| 949 | '(require 'foo nil nil)))))) | 937 | '(require 'foo nil nil))))) |
| 938 | |||
| 939 | (match-expansion | ||
| 940 | (use-package counsel | ||
| 941 | :load-path "site-lisp/swiper" | ||
| 942 | :after ivy | ||
| 943 | :demand t | ||
| 944 | :diminish | ||
| 945 | :bind (("C-*" . counsel-org-agenda-headlines) | ||
| 946 | ("M-x" . counsel-M-x)) | ||
| 947 | :commands (counsel-minibuffer-history | ||
| 948 | counsel-find-library | ||
| 949 | counsel-unicode-char) | ||
| 950 | :preface (preface-code) | ||
| 951 | :init | ||
| 952 | ;; This is actually wrong, but it's just part of the example. | ||
| 953 | (define-key minibuffer-local-map (kbd "M-r") | ||
| 954 | 'counsel-minibuffer-history)) | ||
| 955 | `(progn | ||
| 956 | (eval-and-compile | ||
| 957 | (add-to-list 'load-path "/Users/johnw/.emacs.d/site-lisp/swiper")) | ||
| 958 | (eval-and-compile | ||
| 959 | (preface-code)) | ||
| 960 | (eval-after-load 'ivy | ||
| 961 | '(progn | ||
| 962 | (define-key minibuffer-local-map (kbd "M-r") | ||
| 963 | 'counsel-minibuffer-history) | ||
| 964 | (require 'counsel nil nil) | ||
| 965 | (if (fboundp 'diminish) | ||
| 966 | (diminish 'counsel-mode)) | ||
| 967 | (ignore | ||
| 968 | (bind-keys :package counsel | ||
| 969 | ("C-*" . counsel-org-agenda-headlines) | ||
| 970 | ("M-x" . counsel-M-x)))))))) | ||
| 950 | 971 | ||
| 951 | (ert-deftest use-package-test/:config () | 972 | (ert-deftest use-package-test/:config () |
| 952 | (match-expansion | 973 | (match-expansion |
| @@ -970,11 +991,10 @@ | |||
| 970 | 991 | ||
| 971 | (match-expansion | 992 | (match-expansion |
| 972 | (use-package foo :defer t :config (config)) | 993 | (use-package foo :defer t :config (config)) |
| 973 | `(progn | 994 | `(eval-after-load 'foo |
| 974 | (eval-after-load 'foo | 995 | '(progn |
| 975 | '(progn | 996 | (config) |
| 976 | (config) | 997 | t))) |
| 977 | t)))) | ||
| 978 | 998 | ||
| 979 | (let ((byte-compile-current-file t)) | 999 | (let ((byte-compile-current-file t)) |
| 980 | (match-expansion | 1000 | (match-expansion |