branch: elpa/buttercup commit c59110b927940ec96db8f4c2ff4b494e18f88ce6 Author: Ola Nilsson <ola.nils...@gmail.com> Commit: Ola Nilsson <ola.nils...@gmail.com>
test: Extend with-local-buttercup with some key arguments New key arguments :color, :suites, and :reporter can be used to overridde buttercup-color, buttersup-suites, and buttercup-reporter respectively. Allows code like (with-local-buttercup :color t ...) instead of (with-local-buttercup (let ((buttercup-color t))) ...) --- tests/test-buttercup.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el index cb472d3..076978d 100644 --- a/tests/test-buttercup.el +++ b/tests/test-buttercup.el @@ -36,8 +36,15 @@ items)) (defmacro with-local-buttercup (&rest body) - "Execute BODY with local buttercup state variables." + "Execute BODY with local buttercup state variables. +Keyword arguments kan be used to override the values of `buttercup-KEY'. +\n(fn &keys COLOR SUITES REPORTER &rest BODY)" (declare (debug t) (indent defun)) + ;; extract keyword arguments + (let ((keys '(:color buttercup-color :suites buttercup-suites :reporter buttercup-reporter)) + extra-vars) + (while (plist-member keys (car body)) + (push (list (plist-get keys (pop body)) (pop body)) extra-vars)) `(let (buttercup--after-all buttercup--after-each buttercup--before-all @@ -46,8 +53,9 @@ buttercup--current-suite (buttercup-reporter #'ignore) buttercup-suites - (buttercup-warning-buffer-name " *ignored buttercup warnings*")) - ,@body)) + (buttercup-warning-buffer-name " *ignored buttercup warnings*") + ,@(nreverse extra-vars)) + ,@body))) (defun send-string-to-ansi-buffer (buffer string) "A `send-string-to-terminal' variant that sends STRING to BUFFER.