summaryrefslogtreecommitdiff
path: root/test/lisp/use-package/use-package-tests.el
diff options
context:
space:
mode:
authorJohn Lee <jjl@pobox.com>2020-05-09 19:01:01 +0100
committerJohn Lee <jjl@pobox.com>2020-05-09 23:46:53 +0100
commitf30d5761af12836844b2e3e8da11f649a31d8abf (patch)
treed9a81ac3c2befd83d38a7a7abe8a98abffe34653 /test/lisp/use-package/use-package-tests.el
parent91e5d275af4087f954ac0af75326eb269b984655 (diff)
downloademacs-f30d5761af12836844b2e3e8da11f649a31d8abf.tar.gz
emacs-f30d5761af12836844b2e3e8da11f649a31d8abf.tar.bz2
emacs-f30d5761af12836844b2e3e8da11f649a31d8abf.zip
Even when there's no :config, run any pre/post config hooks
i.e., following the existing docs for use-package-inject-hooks, these hooks are run: use-package--foo--pre-config-hook use-package--foo--post-config-hook This should make config customisations more predictable (for example, spacemacs uses these hooks extensively to allow 'layers' to be customised). I got rid of the "special" default value for :config, because it doesn't seem to be treated any differently than nil. Fixes https://github.com/jwiegley/use-package/issues/785 Copyright-paperwork-exempt: yes
Diffstat (limited to 'test/lisp/use-package/use-package-tests.el')
-rw-r--r--test/lisp/use-package/use-package-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el
index 04a653e30e8..d92a818cdbe 100644
--- a/test/lisp/use-package/use-package-tests.el
+++ b/test/lisp/use-package/use-package-tests.el
@@ -1474,6 +1474,36 @@
(config)
t))))))
+(ert-deftest use-package-test/pre-post-hooks-with-:config ()
+ (let ((use-package-inject-hooks t))
+ (match-expansion
+ (use-package foo :config (config))
+ `(progn
+ (when
+ (run-hook-with-args-until-failure 'use-package--foo--pre-init-hook)
+ (run-hooks 'use-package--foo--post-init-hook))
+ (require 'foo nil nil)
+ (when
+ (run-hook-with-args-until-failure 'use-package--foo--pre-config-hook)
+ (config)
+ (run-hooks 'use-package--foo--post-config-hook))
+ t))))
+
+(ert-deftest use-package-test/pre-post-hooks-without-:config ()
+ ;; https://github.com/jwiegley/use-package/issues/785
+ (let ((use-package-inject-hooks t))
+ (match-expansion
+ (use-package foo)
+ `(progn
+ (when
+ (run-hook-with-args-until-failure 'use-package--foo--pre-init-hook)
+ (run-hooks 'use-package--foo--post-init-hook))
+ (require 'foo nil nil)
+ (when
+ (run-hook-with-args-until-failure 'use-package--foo--pre-config-hook)
+ (run-hooks 'use-package--foo--post-config-hook))
+ t))))
+
(ert-deftest use-package-test-normalize/:diminish ()
(should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
'(foopkg-mode)))