[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup a6f2486 211/340: Merge pull request #150 from Da
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup a6f2486 211/340: Merge pull request #150 from DarwinAwardWinner/suppress-warning-redirect |
Date: |
Thu, 16 Dec 2021 14:59:36 -0500 (EST) |
branch: elpa/buttercup
commit a6f2486299178ead245268aa4e5a646d7fa3cec9
Merge: c2d75e9 c100fad
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #150 from DarwinAwardWinner/suppress-warning-redirect
Implement buttercup-suppress-warning-capture
---
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 966798f 255/340: Correct all docstrings to pass checkdoc, (continued)
- [nongnu] elpa/buttercup 966798f 255/340: Correct all docstrings to pass checkdoc, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b520dcf 257/340: Print test run duration in an apropriate unit, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1fd0d8b 260/340: Set state pending for skipped specs for correct initial count, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b298517 262/340: test: Mark some local function arguments as unused, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8e29f4c 259/340: Extract buttercup--mark-skipped from buttercup-run-discover, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 669ca99 267/340: test: Split make rule test into test-buttercup and test-docs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6655f77 269/340: Update test run duration output in buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e6c09e 271/340: Correct the assume docstring, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6848057 167/340: Bump version: 1.9 → 1.10, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8628d45 208/340: Merge pull request #147 from snogge/suite-local-function, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a6f2486 211/340: Merge pull request #150 from DarwinAwardWinner/suppress-warning-redirect,
ELPA Syncer <=
- [nongnu] elpa/buttercup a019f7a 221/340: Use spy-calls-count as appropriate, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b297b1d 241/340: Revert "Change: (buttercup-define-matcher-for-binary-function) Add newlines", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7903e1a 250/340: Revert "Make it possible to abort test run cleanly", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 521b71b 253/340: Add tests to ensure pending spec state is not overwritten, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9265f83 258/340: Add test for buttercup-suites-total-specs-pending, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b360e35 264/340: test: Add tests for buttercup--mark-skipped, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9b94921 276/340: test: Add tests for buttercup-reporter-batch buttercup-done handling, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 2040757 277/340: test: Add reporter test for buttercup-started with pending specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a91f282 283/340: Handle multiline spec descriptions in buttercup-reporter-batch-color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 532d082 284/340: test: Fix tab stops in send-string-to-ansi-buffer for Emacs 24.3, ELPA Syncer, 2021/12/16