[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-wa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-warning-capture |
Date: |
Thu, 16 Dec 2021 14:59:36 -0500 (EST) |
branch: elpa/buttercup
commit c100fad6384507ffe6329d95c0a3d787db2f0731
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Implement buttercup-suppress-warning-capture
Fixes #124.
---
buttercup.el | 13 +++++++++++++
docs/writing-tests.md | 15 ++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/buttercup.el b/buttercup.el
index 5000735..c12a34c 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1657,6 +1657,7 @@ function is disabled to suppress display of all warning
messages.
The contents of this buffer are then displayed after the test
finishes."
(when (and (null buffer-name)
+ buttercup-warning-buffer-name
(get-buffer buttercup-warning-buffer-name))
(setq buffer-name buttercup-warning-buffer-name))
(if (equal buffer-name buttercup-warning-buffer-name)
@@ -1677,6 +1678,18 @@ finishes."
(white . 37))
"List of text colors.")
+(defmacro buttercup-suppress-warning-capture (&rest body)
+ "Suppress Buttercup's warning capturing within BODY.
+
+Buttercup normally captures all warnings while a test is running
+so it can defer displaying them until after the test is complete.
+However, if you want to catch any warnings yourself as part of
+the test, you need to wrap your code in this macro to suppress
+the capturing behavior."
+ (declare (indent 0))
+ `(let ((buttercup-warning-buffer-name nil))
+ ,@body))
+
(defun buttercup-colorize (string color)
"Format STRING with COLOR."
(let ((color-code (cdr (assoc color buttercup-colors))))
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index 3383467..7be3782 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -636,9 +636,22 @@ Finally, `spy-calls-reset` clears all tracking for a spy.
## Warnings in tests
+By default, Buttercup captures any warning emitted during a test and
+displays them all after the test completes in order to keep the output
+readable. If you need to suppress this (for example if your test deals
+with the warnings itself), you can use the macro
+`buttercup-suppress-warning-capture`.
+
```Emacs-Lisp
(describe "A test"
(it "can issue warnings while running"
(display-warning 'buttercup "This warning should be visible after the test
report.")
- (expect (+ 2 2) :to-equal 4)))
+ (expect (+ 2 2) :to-equal 4))
+
+ (it "can capture its own warnings as part of the test"
+ (buttercup-suppress-warning-capture
+ (display-warning 'buttercup "This warning should be captured in
`collected-output'.")
+ (expect (with-current-buffer "*Warnings*"
+ (buffer-string))
+ :to-match "This warning should be captured"))))
```
- [nongnu] elpa/buttercup 39d625c 173/340: Bump version: 1.11 → 1.12, (continued)
- [nongnu] elpa/buttercup 39d625c 173/340: Bump version: 1.11 → 1.12, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6330610 176/340: Add more markdown running functions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3d3aff9 178/340: Set file local code-style variables in test-buttercup.el, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 553529f 181/340: Remove obsolete buttercup-xdescribe, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5821cd0 184/340: Merge pull request #131 from snogge/markdown, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a394fea 191/340: Bump version: 1.13 → 1.14, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7cea4c6 192/340: Test buttercup-run, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b410c78 193/340: Separate return code from reporter, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9b230dc 202/340: Fix the "should print the elapsed time for all specs" test, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9d172a7 205/340: Merge pull request #145 from snogge/test-fixes, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-warning-capture,
ELPA Syncer <=
- [nongnu] elpa/buttercup c994aea 212/340: Add LICENSE file., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d9ce620 213/340: Merge branch 'license-file' into master, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 49f01fc 219/340: Merge branch 'master' into test-emacs-26.3, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 25462dd 223/340: Record calls to spied-on functions that throw errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bf48137 224/340: Add some tests for error-call recording, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc19598 225/340: Add examples for checking return value and thrown signal of a spy, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6590360 226/340: Fix a few typos and other small errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8a28489 230/340: Bump version: 1.18 → 1.19, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e40587 231/340: Tweak the spy-contexts to be more backward compatible, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 60028db 236/340: docs: Clarify the spy lifespan in writing-tests.md, ELPA Syncer, 2021/12/16