[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup bc13b53 183/340: Merge pull request #133 from sn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup bc13b53 183/340: Merge pull request #133 from snogge/fix-specs-in-pending-suites |
Date: |
Thu, 16 Dec 2021 14:59:30 -0500 (EST) |
branch: elpa/buttercup
commit bc13b53deb1c2b590c33f5e03508b864a0116d5e
Merge: d07dbf3 553529f
Author: Jorgen Schäfer <Jorgen.Schaefer@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #133 from snogge/fix-specs-in-pending-suites
Keep specs in pending suites, fixes #116
---
buttercup.el | 60 ++++++++++++++++++++++++++++++++++++-------------
docs/writing-tests.md | 11 ++++-----
tests/test-buttercup.el | 42 +++++++++++++++++++++++++---------
3 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index 1ca3898..d32e92b 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -915,27 +915,55 @@ FUNCTION is a function containing the body instructions
passed to
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Disabled Suites: xdescribe
-(defmacro xdescribe (description &rest body)
- "Like `describe', but mark the suite as disabled.
+(defun buttercup--disable-specs (forms)
+ "Process FORMS to make any suites or specs pending."
+ (when (eq (car forms) :var)
+ (setq forms (cddr forms)))
+ (let (retained inner)
+ (dolist (form forms (nreverse retained))
+ (pcase form
+ ;; Make it pending by just keeping the description
+ (`(it ,description . ,_)
+ (push (list 'it description) retained))
+ (`(xit ,description . ,_)
+ (push (list 'it description) retained))
+ ;; Just make nested describes into xdescribes and handle them
+ ;; in another macro invocation
+ (`(describe . ,tail)
+ (push (cons 'xdescribe tail) retained))
+ (`(xdescribe . ,tail)
+ (push (cons 'xdescribe tail) retained))
+ ;; Special case to ignore before-* and after-* forms
+ (`(before-each . ,_)) ; nop
+ (`(after-each . ,_)) ; nop
+ (`(before-all . ,_)) ; nop
+ (`(after-all . ,_)) ; nop
+ ;; Any list starting with a list, like a let varlist.
+ ((and (pred consp)
+ ls
+ (guard (consp (car ls))))
+ (dolist (elt (buttercup--disable-specs ls))
+ (push elt retained)))
+ ;; Any function call list
+ (`(,_ . ,tail)
+ (dolist (elt (buttercup--disable-specs tail))
+ (push elt retained)))
+ ;; non-cons items
+ ((and elt (guard (not (consp elt))))) ; nop
+ (_
+ (error "Unrecognized form in `xdescribe': `%s'" (pp-to-string form)))
+ ))))
-A disabled suite is not run.
+(defmacro xdescribe (description &rest body)
+ "Like `describe', but mark any specs as disabled.
DESCRIPTION is a string. BODY is a sequence of instructions,
mainly calls to `describe', `it' and `before-each'."
(declare (indent 1))
- `(buttercup-xdescribe ,description (lambda () ,@body)))
-
-(defun buttercup-xdescribe (description function)
- "Like `buttercup-describe', but mark the suite as disabled.
-
-A disabled suite is not run.
-
-DESCRIPTION has the same meaning as in `xdescribe'. FUNCTION
-is ignored.
-`describe'."
- (ignore function)
- (buttercup-describe description (lambda ()
- (signal 'buttercup-pending "PENDING"))))
+ `(describe ,description
+ ,@(buttercup--disable-specs body)
+ ;; make sure the suite is marked as pending
+ (signal 'buttercup-pending "PENDING")))
;;;;;;;;;;;;;;;;;;;;;;
;;; Pending Specs: xit
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index b980a18..c478111 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -298,10 +298,11 @@ walks through the `after-each` functions similarly.
## Disabling Suites
-Suites and specs can be disabled with the `xdescribe` and `xit`
-macros, respectively. These suites and any specs inside them are
-skipped when run and thus their results will not appear in the
-results.
+Suites and specs can be disabled by marking them as pending with the
+`xdescribe` and `xit` macros, respectively. Any suites or specs inside
+a `xdescribe' suite is also pending. Pending suites and specs will be
+listed as pending in the results, but the containing code will not be
+run.
```Emacs-Lisp
(xdescribe "A spec"
@@ -316,7 +317,7 @@ results.
## Pending Specs
-Pending specs do not run.
+Pending specs do not run, but will be listed in the results.
Any spec declared with `xit` is marked as pending.
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 54df118..d7ff1d9 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -306,7 +306,7 @@
;;; Suites: describe
(describe "The `describe' macro"
- (it "should expand to a simple call to the describe function"
+ (it "should expand to a simple call to the buttercup-describe function"
(expect (macroexpand '(describe "description" (+ 1 1)))
:to-equal
'(buttercup-describe "description" (lambda () (+ 1 1)))))
@@ -461,19 +461,36 @@
(it "expands directly to a function call"
(expect (macroexpand '(xdescribe "bla bla" (+ 1 1)))
:to-equal
- '(buttercup-xdescribe "bla bla" (lambda () (+ 1 1))))))
-
-(describe "The `buttercup-xdescribe' function"
- (it "should be a no-op"
- (expect (buttercup-xdescribe
- "bla bla"
- (lambda () (error "Should not happen")))
- :not :to-throw))
+ '(buttercup-describe "bla bla"
+ (lambda ()
+ (signal 'buttercup-pending "PENDING")))))
+
+ (it "changes contained it-specs to pending specs"
+ (expect (macroexpand-all
+ '(xdescribe "bla bla"
+ (let ((a 1) b (c 2) (d (it "nested" (+ 1 1))))
+ (it "spec1" (+ 1 1))
+ (describe "inner suite"
+ (it "inner spec"))
+ (xit "spec2" (+ 1 1)))))
+ :to-equal
+ '(buttercup-describe
+ "bla bla"
+ #'(lambda ()
+ (buttercup-xit "nested")
+ (buttercup-xit "spec1")
+ (buttercup-describe
+ "inner suite"
+ #'(lambda ()
+ (buttercup-xit "inner spec")
+ (signal 'buttercup-pending "PENDING")))
+ (buttercup-xit "spec2")
+ (signal 'buttercup-pending "PENDING")))))
(it "should add a pending suite"
(let ((buttercup--current-suite nil)
(buttercup-suites nil))
- (buttercup-xdescribe
+ (xdescribe
"bla bla"
(lambda () nil))
(expect (buttercup-suite-status (car buttercup-suites))
@@ -960,6 +977,9 @@
(expect (length (cdr specs)) :to-equal 1)
(expect (cl-caadr specs) :to-equal "should fontify special
keywords")))))
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; sentence-end-double-space: nil
+;; End:
(provide 'test-buttercup)
-
;;; test-buttercup.el ends here
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., (continued)
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c7df9f6 069/340: Add 24.5., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-specs-defined function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ea8effb 095/340: Add the :var argument to describe, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 23472e9 099/340: :to-match: Show correct error messages, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cc52444 107/340: feature/windows-bin-support: support for windows, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3ef90b4 100/340: :to-match: Don't switch t/nil!, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ab2a558 111/340: Add projectile integration info to Readme, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0124cc4 129/340: Signal an error when ":to-throw" is used on a non-function (#97), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 31e765b 142/340: Do not suppress errors while loading test files, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bc13b53 183/340: Merge pull request #133 from snogge/fix-specs-in-pending-suites,
ELPA Syncer <=
- [nongnu] elpa/buttercup ca3ba8e 185/340: Merge pull request #130 from snogge/travis-update, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d6cf530 072/340: Clean up the interactive reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 68c5ef5 076/340: Only load .el files during discovery., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 14718c0 081/340: Use the new Travis infrastructure, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d00c164 083/340: Display description for pending specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ad901b5 149/340: Do not modify global match data in matchers, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c1187b3 152/340: Extract function buttercup-suites-total-spces-status, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f565eda 157/340: Extract super-struct buttercup-suite-or-spec, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0c1dcda 161/340: Fix docstring of buttercup--specs-and-suite, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8d27bb9 169/340: Bump version: 1.10 → 1.11, ELPA Syncer, 2021/12/16