emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup c1187b3 152/340: Extract function buttercup-suit


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup c1187b3 152/340: Extract function buttercup-suites-total-spces-status
Date: Thu, 16 Dec 2021 14:59:23 -0500 (EST)

branch: elpa/buttercup
commit c1187b34c11cdf4030c57427261f3af4d6374b15
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Jorgen Schäfer <Jorgen.Schaefer@gmail.com>

    Extract function buttercup-suites-total-spces-status
    
    Having a single function that handles all statuses allows for
    reporters using more types of status such as error for specs that
    throw unexpectedly.
---
 buttercup.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/buttercup.el b/buttercup.el
index ffbc22d..a482ff6 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -714,26 +714,24 @@ See also `buttercup-define-matcher'."
         (setq nspecs (1+ nspecs))))
     nspecs))
 
-(defun buttercup-suites-total-specs-pending (suite-list)
-  "Return the number of specs marked as pending in all suites in SUITE-LIST."
+(defun buttercup-suites-total-specs-status (suite-list status)
+  "Return the number of specs in SUITE-LIST marked with STATUS."
   (let ((nspecs 0))
-    (dolist (spec-or-suite (buttercup--specs-and-suites suite-list))
+    (dolist (spec-or-suite (buttercup--specs-and-suites suite-list) nspecs)
       (when (and (buttercup-spec-p spec-or-suite)
-                 (eq (buttercup-spec-status spec-or-suite) 'pending))
-        (setq nspecs (1+ nspecs))))
-    nspecs))
+                 (eq (buttercup-spec-status spec-or-suite) status))
+        (setq nspecs (1+ nspecs))))))
+
+(defun buttercup-suites-total-specs-pending (suite-list)
+  "Return the number of specs marked as pending in all suites in SUITE-LIST."
+  (buttercup-suites-total-specs-status suite-list 'pending))
 
 (defun buttercup-suites-total-specs-failed (suite-list)
   "Return the number of failed specs in all suites in SUITE-LIST."
-  (let ((nspecs 0))
-    (dolist (spec-or-suite (buttercup--specs-and-suites suite-list))
-      (when (and (buttercup-spec-p spec-or-suite)
-                 (eq (buttercup-spec-status spec-or-suite) 'failed))
-        (setq nspecs (1+ nspecs))))
-    nspecs))
+  (buttercup-suites-total-specs-status suite-list 'failed))
 
 (defun buttercup--specs-and-suites (spec-or-suite-list)
-  "Return the number of specs defined in SUITE-OR-SPEC and its children."
+  "Return the number of specs defined in SPEC-OR-SUITE-LIST and its children."
   (let ((specs-and-suites nil))
     (dolist (spec-or-suite spec-or-suite-list)
       (setq specs-and-suites (append specs-and-suites



reply via email to

[Prev in Thread] Current Thread [Next in Thread]