[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The batch reporter" suite |
Date: |
Thu, 16 Dec 2021 14:59:49 -0500 (EST) |
branch: elpa/buttercup
commit cf4eee8a3cb0a85a0399056e43bcb18259c380e1
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
test: Verify output in the "The batch reporter" suite
Use buttercup--print-collector to collect the output as it would
appear on the terminal and verify that it matches expectation.
The tests used to verify the calls to buttercup--print, but this is
fragile at best.
"should print the elasped time for all specs" is removed as the
elapsed time is checked in all other tests.
---
tests/test-buttercup.el | 72 +++++++++++--------------------------------------
1 file changed, 16 insertions(+), 56 deletions(-)
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index f926287..474da8d 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1075,7 +1075,6 @@ text properties using `ansi-color-apply'."
print-buffer (generate-new-buffer "*btrcp-reporter-test*"))
(buttercup-suite-add-child parent-suite child-suite)
(buttercup-suite-add-child child-suite spec)
- (spy-on 'buttercup--print)
(spy-on 'send-string-to-terminal :and-call-fake
(apply-partially #'send-string-to-ansi-buffer print-buffer))
;; Convenience function
@@ -1089,35 +1088,21 @@ text properties using `ansi-color-apply'."
(setq print-buffer nil))
(describe "on the buttercup-started event"
- (it "should emit the number of specs"
+ (it "should print the number of specs"
(let ((buttercup-reporter-batch--start-time nil)
(buttercup-reporter-batch--failures nil))
(buttercup-reporter-batch 'buttercup-started (list parent-suite)))
-
- (expect 'buttercup--print
- :to-have-been-called-with
- "Running %s specs.\n\n"
- 1)))
+ (expect (buttercup-output) :to-equal "Running 1 specs.\n\n")))
(describe "on the suite-started event"
(it "should emit an indented suite description"
(buttercup-reporter-batch 'suite-started child-suite)
-
- (expect 'buttercup--print
- :to-have-been-called-with
- "%s%s\n"
- " "
- "child-suite")))
+ (expect (buttercup-output) :to-equal " child-suite\n")))
(describe "on the spec-started event"
(it "should emit an indented spec description"
(buttercup-reporter-batch 'spec-started spec)
-
- (expect 'buttercup--print
- :to-have-been-called-with
- "%s%s"
- " "
- "spec")))
+ (expect (buttercup-output) :to-equal " spec")))
(describe "on the spec-done event"
(it "should print no status tag for a passed spec"
@@ -1125,65 +1110,40 @@ text properties using `ansi-color-apply'."
(setf (buttercup-spec-failure-description spec) "DONTSHOW")
(buttercup--set-end-time spec)
(buttercup-reporter-batch 'spec-done spec)
-
- (expect (mapconcat (apply-partially #'apply #'format)
- (spy-calls-all-args 'buttercup--print)
- "")
- :to-match "^\\s-*([0-9]+\\.[0-9]+\\(h\\|m\\|m?s\\))\n$"))
+ (expect (buttercup-output) :to-equal
+ (format " (%s)\n" (buttercup-elapsed-time-string spec)))
+ )
(it "should say FAILED for a failed spec"
(setf (buttercup-spec-status spec) 'failed)
-
(let ((buttercup-reporter-batch--failures nil))
(buttercup-reporter-batch 'spec-done spec))
-
- (expect (mapconcat (apply-partially #'apply #'format)
- (spy-calls-all-args 'buttercup--print)
- "")
- :to-match "FAILED\\(\\s-+.*\\)?\n$"))
+ (expect (buttercup-output) :to-equal
+ (format " FAILED (%s)\n" (buttercup-elapsed-time-string
spec)))
+ )
(it "should output the failure-description for a pending spec"
(setf (buttercup-spec-status spec) 'pending
(buttercup-spec-failure-description spec) "DESCRIPTION")
(let ((buttercup-reporter-batch--failures nil))
(buttercup-reporter-batch 'spec-done spec))
- (expect (mapconcat (apply-partially #'apply #'format)
- (spy-calls-all-args 'buttercup--print) "")
- :to-match "DESCRIPTION\\(\\s-+.*\\)?\n$"))
+ (expect (buttercup-output) :to-equal
+ (format " DESCRIPTION (%s)\n" (buttercup-elapsed-time-string
spec)))
+ )
(it "should throw an error for an unknown spec status"
(setf (buttercup-spec-status spec) 'unknown)
-
(expect (buttercup-reporter-batch 'spec-done spec)
- :to-throw))
-
- (it "should print the elapsed time for all specs"
- (dolist (state '(pending failed passed))
- (spy-calls-reset 'buttercup--print)
- (setq spec (make-buttercup-spec :description "spec"
- :parent child-suite
- :status state
- :failure-description ""))
- (buttercup--set-start-time spec)
- (buttercup--set-end-time spec)
- (let ((buttercup-reporter-batch--failures nil))
- (buttercup-reporter-batch 'spec-done spec))
-
- (expect (mapconcat (apply-partially #'apply #'format)
- (spy-calls-all-args 'buttercup--print)
- "")
- :to-match " ([0-9]+\\(\\.[0-9]+\\)?\\(h\\|m\\|m?s\\))\n$"))))
+ :to-throw)))
(describe "on the suite-done event"
(it "should emit a newline at the end of the top-level suite"
(buttercup-reporter-batch 'suite-done parent-suite)
-
- (expect 'buttercup--print :to-have-been-called-with "\n"))
+ (expect (buttercup-output) :to-equal "\n"))
(it "should not emit anything at the end of other suites"
(buttercup-reporter-batch 'suite-done child-suite)
-
- (expect 'buttercup--print :not :to-have-been-called)))
+ (expect (buttercup-output) :to-equal "")))
(describe "on the buttercup-done event"
;; This is a lie. It should do a ton more stuff. We should test
- [nongnu] elpa/buttercup 0e40587 231/340: Tweak the spy-contexts to be more backward compatible, (continued)
- [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
- [nongnu] elpa/buttercup 9c4b473 237/340: test: Add missing apostrophe in spec title, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 90654ec 238/340: Update some docstrings, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 178c795 242/340: README: Add '-L .' to test runner example, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc4276a 247/340: Make it possible to abort test run cleanly, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dbcd3d4 256/340: Calculate total test run time with current-time, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c83ba7d 268/340: Extract function buttercup-elapsed-time-string, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 38cfa6f 270/340: Fix spy-on on Emacs 24.3 for symbols that are not fbound, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 81bfed4 272/340: test: Add utility function send-string-to-ansi-buffer, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The batch reporter" suite,
ELPA Syncer <=
- [nongnu] elpa/buttercup 4159111 275/340: test: Verify full line for reporter spec-done tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fbb790b 278/340: test: Add tests for buttercup-started and buttercup-reporter-batch-color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d563e18 281/340: test: Add color tests for suite-done, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b910b71 285/340: Extract buttercup--indented-description from the batch reporters, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e71a40f 287/340: Make sure carriage movement characters are not colorized, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a22fc29 288/340: Bump version: 1.21 → 1.22, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dde8651 290/340: Add new function buttercup--spec-mark-pending and use it, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c59110b 291/340: test: Extend with-local-buttercup with some key arguments, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d443ecb 293/340: Clarify patterns in bin/buttercup, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4d1acb8 294/340: test: Rewrite buttercup-run tests using spies, ELPA Syncer, 2021/12/16