[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 41424d5 292/340: Add new public function butterc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 41424d5 292/340: Add new public function buttercup-mark-skipped |
Date: |
Thu, 16 Dec 2021 14:59:53 -0500 (EST) |
branch: elpa/buttercup
commit 41424d5fa0732c96cd54fdbbcb8800a6e6170f34
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Add new public function buttercup-mark-skipped
which wraps buttercup--mark-skipped. buttercup-mark-skipped should
be used to mark specs as skipped *before* running the tests.
Solves the test filtering part of #161.
---
buttercup.el | 32 +++++++++++++++++++++++---------
tests/test-buttercup.el | 41 ++++++++++++++++++++++++++++++-----------
2 files changed, 53 insertions(+), 20 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index 1d369e3..12e5b06 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1383,18 +1383,32 @@ current directory."
(when (not (string-match "\\(^\\|/\\)\\." (file-relative-name file)))
(load file nil t))))
(when patterns
- (buttercup--mark-skipped buttercup-suites patterns))
+ (buttercup-mark-skipped (regexp-opt patterns) t))
(buttercup-run)))
-(defun buttercup--mark-skipped (suites patterns)
- "Mark any spec in SUITES not matching PATTERNS as skipped.
-SUITES is a list of suites. PATTERNS is a list of regexps."
+(defun buttercup-mark-skipped (matcher &optional reverse)
+ "Mark any spec that match MATCHER as skipped.
+MATCHER can be either a regex or a function taking a spec as the
+single argument. If REVERSE is non-nil, specs will be marked as
+pending when MATCHER does not match."
+ (cl-etypecase matcher
+ (string (buttercup--mark-skipped
+ buttercup-suites
+ (lambda (spec)
+ (string-match matcher (buttercup-spec-full-name spec)))
+ reverse))
+ (function (buttercup--mark-skipped buttercup-suites matcher reverse))))
+
+(defun buttercup--mark-skipped (suites predicate &optional reverse-predicate)
+ "Mark all specs in SUITES as skipped if PREDICATE(spec) is true.
+If REVERSE-PREDICATE is non-nil, mark spec where PREDICATE(spec)
+is false."
(dolist (spec (buttercup--specs suites))
- (let ((spec-full-name (buttercup-spec-full-name spec)))
- (unless (cl-dolist (p patterns)
- (when (string-match p spec-full-name)
- (cl-return t)))
- (buttercup--spec-mark-pending spec "SKIPPED")))))
+ ;; cond implements (xor reverse-predicate (funcall predicate
+ ;; spec)) as xor is introduced in Emacs 27
+ (when (cond ((not reverse-predicate) (funcall predicate spec))
+ ((not (funcall predicate spec)) reverse-predicate))
+ (buttercup--spec-mark-pending spec "SKIPPED"))))
;;;###autoload
(defun buttercup-run-markdown-buffer (&rest markdown-buffers)
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 076978d..da69317 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -335,8 +335,8 @@ text properties using `ansi-color-apply'."
(expect (buttercup-suites-total-specs-pending suites)
:to-equal 2)))
(it "should also count skipped specs"
- (with-local-buttercup
- (buttercup--mark-skipped suites (list "skipped"))
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped "skipped" t)
(expect (buttercup-suites-total-specs-pending suites)
:to-equal 3))))
@@ -1370,7 +1370,7 @@ text properties using `ansi-color-apply'."
:to-have-been-called-with
"Hello, world")))
-(describe "The `buttercup--mark-skipped' function"
+(describe "The `buttercup-mark-skipped' function"
:var (suites)
(before-each
(with-local-buttercup
@@ -1389,27 +1389,46 @@ text properties using `ansi-color-apply'."
(it "2-3 spec" (ignore))
(it "2-4 spec" (ignore)))
(setq suites buttercup-suites)))
- (it "should do nothing with a match-all pattern"
+ (it "should do nothing with a reversed match-all pattern"
(expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
(expect (buttercup-suites-total-specs-pending suites) :to-equal 5)
- (buttercup--mark-skipped suites '("."))
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped "." t))
(expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
(expect (buttercup-suites-total-specs-pending suites) :to-equal 5)
- (with-local-buttercup
- (setq buttercup-suites suites)
+ (with-local-buttercup :suites suites
(buttercup-run))
(expect (buttercup-suites-total-specs-pending suites) :to-equal 5)
(expect (cl-count "SKIPPED" (buttercup--specs suites)
:key #'buttercup-spec-failure-description)
:to-equal 0))
- (it "should mark all specs as pending with no pattern"
- (buttercup--mark-skipped suites '())
+ (it "should mark all specs as pending with a reversed match none pattern"
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped "[z-a]" t))
(expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
(expect (buttercup-suites-total-specs-pending suites) :to-equal 11))
(it "should handle multiple patterns"
- (buttercup--mark-skipped suites '("1-1-[1-2]" "[12]-4"))
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped (regexp-opt '("1-1-1" "1-1-2" "1-4" "2-4")) t))
+ (expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
+ (expect (buttercup-suites-total-specs-pending suites) :to-equal 8))
+ (it "should support predicates"
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped
+ (lambda (spec) (= 2 (cl-count ?- (buttercup-spec-full-name spec))))))
(expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
- (expect (buttercup-suites-total-specs-pending suites) :to-equal 8)))
+ (expect (buttercup-suites-total-specs-pending suites) :to-equal 10))
+ (it "should support reversed predicates"
+ (with-local-buttercup :suites suites
+ (buttercup-mark-skipped
+ (lambda (spec) (= 2 (cl-count ?- (buttercup-spec-full-name spec))))
+ t))
+ (expect (buttercup-suites-total-specs-defined suites) :to-equal 11)
+ (expect (buttercup-suites-total-specs-pending suites) :to-equal 6))
+ (it "should signal an error for invalid matchers"
+ (with-local-buttercup
+ (expect (buttercup-mark-skipped 4) :to-throw)))
+ )
;;;;;;;;;;;;;;;;;;;;;
;;; ERT Compatibility
- [nongnu] elpa/buttercup 7903e1a 250/340: Revert "Make it possible to abort test run cleanly", (continued)
- [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
- [nongnu] elpa/buttercup 8afc407 286/340: Switch from to pcase for spec-done in buttercup-reporter-batch-color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d5c3ed5 289/340: Switch to Github Actions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 41424d5 292/340: Add new public function buttercup-mark-skipped,
ELPA Syncer <=
- [nongnu] elpa/buttercup 5752a57 295/340: Control errors from buttercup-run with noerror argument, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 2d77e18 300/340: test: Correct descriptions for some suite-done specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d41c6dc 301/340: Extract buttercup-reporter-batch--print-summary, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 74e74e2 302/340: Extract buttercup-reporter-batch--print-failed-spec-report, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 52f0bec 305/340: Make buttercup-colorize treat nil as no color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a8f4cff 311/340: test: Correct descriptions for ERT compatibility specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 995a4f1 312/340: Add missing docstrings, correct some other docstrings, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 110a9b6 314/340: test: Use pretty traceback, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a9647cb 316/340: Bump version: 1.22 → 1.23, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b76ff35 317/340: Update buttercup.bat to handle all options, ELPA Syncer, 2021/12/16