[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 159fe3c 203/340: Really fix the buttercup-run te
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 159fe3c 203/340: Really fix the buttercup-run tests |
Date: |
Thu, 16 Dec 2021 14:59:34 -0500 (EST) |
branch: elpa/buttercup
commit 159fe3c376c3c2e458fef61e90303c15c27f747f
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Really fix the buttercup-run tests
The fix in 672bce1276c47e7c09eae66593168b83f445a8c7 was not enough.
`buttercup-suites' was not correctly scoped, and somehow the global
value was overwritten. The result being an incorrect number of run
tests being reported at the end of the test run.
I have no clue why let-binding `buttercup-suites' in each spec works
better, but it does.
To get it all to work on Emacs 24.3 I had to drop some of the cl-flet
for less elegant solutions.
---
tests/test-buttercup.el | 57 +++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 26 deletions(-)
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index bbcb1f3..db3df09 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -995,36 +995,41 @@
:to-throw)))))
(describe "The `buttercup-run' function"
- :var (buttercup-suites parent-suite child-suite spec)
- (cl-flet (((reporter (event arg) (ignore event arg))))
- (before-each
- (setq parent-suite (make-buttercup-suite :description "parent-suite")
- child-suite (make-buttercup-suite :description "child-suite")
- spec (make-buttercup-spec :description "spec")
- buttercup-suites (list parent-suite))
- (buttercup-suite-add-child parent-suite child-suite)
- (buttercup-suite-add-child child-suite spec)
- (spy-on 'reporter))
- (it "should raise an error if at least one spec failed"
- (setf (buttercup-spec-status spec) 'failed)
- (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
- (buttercup-reporter 'reporter))
- (expect (buttercup-run) :to-throw)))
- (it "should call the reporter twice with events buttercup-started and
-done"
- (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
- (buttercup-reporter 'reporter))
+ :var (parent-suite child-suite spec reporter)
+ (before-each
+ (ignore reporter)
+ (setf (symbol-function 'reporter) (lambda (event arg) (ignore event arg)))
+ (setq parent-suite (make-buttercup-suite :description "parent-suite")
+ child-suite (make-buttercup-suite :description "child-suite")
+ spec (make-buttercup-spec :description "spec"))
+ (buttercup-suite-add-child parent-suite child-suite)
+ (buttercup-suite-add-child child-suite spec)
+ (spy-on 'reporter))
+ (it "should raise an error if at least one spec failed"
+ (setf (buttercup-spec-status spec) 'failed)
+ (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
+ (buttercup-reporter 'reporter))
+ (let ((buttercup-suites (list parent-suite)))
+ (expect (buttercup-run) :to-throw))))
+ (it "should call the reporter twice with events buttercup-started and -done"
+ (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
+ (buttercup-reporter 'reporter))
+ (let ((buttercup-suites (list parent-suite)))
(expect (buttercup-run) :not :to-throw)
(expect 'reporter :to-have-been-called-times 2)
(expect 'reporter :to-have-been-called-with 'buttercup-started
buttercup-suites)
(expect 'reporter :to-have-been-called-with 'buttercup-done
buttercup-suites)))
- (it "should call `buttercup--run-suite once per suite"
- (cl-flet (((runner (suite) (ignore suite))))
- (spy-on 'runner)
- (cl-letf (((symbol-function 'buttercup--run-suite) #'runner)
- (buttercup-reporter 'reporter)
- (buttercup-suites (make-list 5 parent-suite)))
- (expect (buttercup-run) :not :to-throw)
- (expect 'runner :to-have-been-called-times 5))))))
+ )
+ (it "should call `buttercup--run-suite once per suite"
+ (let ((buttercup-suites (list parent-suite)) runner)
+ (ignore runner)
+ (setf (symbol-function 'runner) (lambda (suite) (ignore suite)))
+ (spy-on 'runner)
+ (cl-letf (((symbol-function 'buttercup--run-suite) #'runner)
+ (buttercup-reporter 'reporter)
+ (buttercup-suites (make-list 5 parent-suite)))
+ (expect (buttercup-run) :not :to-throw)
+ (expect 'runner :to-have-been-called-times 5)))))
(describe "The `buttercup--print' function"
(before-each
- [nongnu] elpa/buttercup bf0e1da 049/340: Rename tar target to release and add compile and clean targets., (continued)
- [nongnu] elpa/buttercup bf0e1da 049/340: Rename tar target to release and add compile and clean targets., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 17f3cf5 062/340: Remove error in favor of failed., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f3d6709 074/340: Use relative path when testing for dotfiles in current project, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup acccc0f 179/340: Modify xdescribe to keep all contained specs as pending, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d07dbf3 182/340: Merge pull request #129 from snogge/fix-obsolete-aliases, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 079ef3e 186/340: Bump version: 1.12 → 1.13, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1998ae3 188/340: Drop unused variable in buttercup--disable-specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup edcffde 189/340: Add start and end times to each suite or spec, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 075b318 198/340: Add support for :var*, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1c762a5 200/340: Add documentation for :var and :var*, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 159fe3c 203/340: Really fix the buttercup-run tests,
ELPA Syncer <=
- [nongnu] elpa/buttercup d2b6692 206/340: Bump version: 1.16 → 1.17, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e62ce43 207/340: test: Do not leak functions from "The Spy " test suite, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8b3cfad 214/340: Update test for new warning capture suppression behavior, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1567c03 215/340: Add emacs-26.3 to CI config, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6cf8041 229/340: Update writing-tests.md to describe new spy context structs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c720cef 233/340: Merge pull request #146 from DarwinAwardWinner/spy-record-errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b2edd35 235/340: Change: (buttercup-define-matcher-for-binary-function) Add newlines, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 818c150 239/340: docs: Clarify the difference between :var and `let', ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d8ab09d 244/340: Update documentation for the --pattern option in running-tests.md, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup adba24e 246/340: Bump version: 1.19 → 1.20, ELPA Syncer, 2021/12/16