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

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

[nongnu] elpa/buttercup e7e5d22 248/340: Add an option to immediately ab


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup e7e5d22 248/340: Add an option to immediately abort Buttercup run if a test fails
Date: Thu, 16 Dec 2021 14:59:44 -0500 (EST)

branch: elpa/buttercup
commit e7e5d22572f37f55997122928fc62b073ab57c49
Author: Paul Pogonyshev <pogonyshev@gmail.com>
Commit: Jorgen Schäfer <Jorgen.Schaefer@gmail.com>

    Add an option to immediately abort Buttercup run if a test fails
---
 bin/buttercup           |  4 +++-
 buttercup.el            | 10 +++++++++-
 tests/test-buttercup.el |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bin/buttercup b/bin/buttercup
index 606436b..962cf07 100755
--- a/bin/buttercup
+++ b/bin/buttercup
@@ -31,6 +31,8 @@ Buttercup options:
                           which case tests will be run if they match
                           any of the given patterns.
 
+--abort-on-failure, -a  Abort test execution if any test fails.
+
 --no-color, -c          Do not colorize test output.
 
 --traceback STYLE       When printing backtraces for errors that occur
@@ -70,7 +72,7 @@ do
             shift
             shift
             ;;
-        "-c"|"--no-color")
+        "-c"|"--no-color"|"-a"|"--abort-on-failure")
             BUTTERCUP_ARGS+=("$1")
             shift
             ;;
diff --git a/buttercup.el b/buttercup.el
index 2e7afa8..69020ca 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -671,6 +671,9 @@ See also `buttercup-define-matcher'."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Suite and spec data structures
 
+(defvar buttercup-stop-on-first-failure nil
+  "Abort Buttercup testing if any spec fails.")
+
 (cl-defstruct buttercup-suite-or-spec
   ;; The name of this specific suite
   description
@@ -1361,6 +1364,9 @@ current directory."
        ((member (car args) '("-c" "--no-color"))
         (setq buttercup-color nil)
         (setq args (cdr args)))
+       ((member (car args) '("-a" "--abort-on-failure"))
+        (setq buttercup-stop-on-first-failure t)
+        (setq args (cdr args)))
        (t
         (push (car args) dirs)
         (setq args (cdr args)))))
@@ -1523,7 +1529,9 @@ failed and pending specs."
                 '(passed pending))
       (setf (buttercup-suite-or-spec-status suite-or-spec) status
             (buttercup-suite-or-spec-failure-description suite-or-spec) 
description
-            (buttercup-suite-or-spec-failure-stack suite-or-spec) stack))))
+            (buttercup-suite-or-spec-failure-stack suite-or-spec) stack)
+      (when (and buttercup-stop-on-first-failure (eq status 'failed))
+        (signal 'buttercup-abort "Aborting early because of the failure")))))
 
 ;;;;;;;;;;;;;
 ;;; Reporters
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index a73f2ee..db61f21 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -332,6 +332,7 @@
          (buttercup--cleanup-functions :invalid)
          buttercup--current-suite
          (buttercup-reporter #'ignore)
+         buttercup-stop-on-first-failure
          buttercup-suites
          (buttercup-warning-buffer-name " *ignored buttercup warnings*"))
      ,@body))



reply via email to

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