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

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

[nongnu] elpa/buttercup 0e5eae0 321/340: Merge pull request #192 from sn


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 0e5eae0 321/340: Merge pull request #192 from snogge/re-patterns
Date: Thu, 16 Dec 2021 14:59:59 -0500 (EST)

branch: elpa/buttercup
commit 0e5eae0766a33b5c8997e1477e3914d5c8ba3d29
Merge: 4d974d2 6c3bb75
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #192 from snogge/re-patterns
    
    Re-enable regex patterns on the command line, fix #191
---
 bin/buttercup           |  9 +++++----
 bin/buttercup.bat       | 25 ++++++++++++++++++++++++-
 buttercup.el            | 17 ++++++++++++-----
 tests/test-buttercup.el |  6 ++++--
 4 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/bin/buttercup b/bin/buttercup
index 8562905..601a8e0 100755
--- a/bin/buttercup
+++ b/bin/buttercup
@@ -29,10 +29,11 @@ Buttercup options:
 --pattern, -p PATTERN   Only run tests with names matching PATTERN.
                           This option can be used multiple times, in
                           which case tests will be run if they match
-                          any of the given patterns. PATTERN is
-                          matched as a substring of the full test
-                          description (the concatenation of the test
-                          and all paremt suites descriptions).
+                          any of the given patterns. PATTERN should be
+                          an Emacs regex that will be matched against
+                          the full test description (the concatenation
+                          of the test and all parent suites
+                          descriptions).
 
 --no-skip               Do not print the descriptions for tests that
                           are filtered out with "--pattern" or disabled
diff --git a/bin/buttercup.bat b/bin/buttercup.bat
index 092230a..edff81d 100644
--- a/bin/buttercup.bat
+++ b/bin/buttercup.bat
@@ -33,7 +33,19 @@ echo.
 echo --pattern, -p PATTERN   Only run tests with names matching PATTERN.
 echo                           This option can be used multiple times, in
 echo                           which case tests will be run if they match
-echo                           any of the given patterns.
+echo                           any of the given patterns. PATTERN should be
+echo                           an Emacs regex that will be matched against
+echo                           the full test description (the concatenation
+echo                           of the test and all parent suites
+echo                           descriptions).
+echo.
+echo --no-skip               Do not print the descriptions for tests that
+echo                           are filtered out with "--pattern" or disabled
+echo                           with "xit". Tests skipped wiath "assume" will
+echo                           still be priuted,
+echo.
+echo --only-error            Only print failed tests and their containing 
suites.
+echo                           Implies "--no-skip".
 echo.
 echo --no-color, -c          Do not colorize test output.
 echo.
@@ -49,6 +61,8 @@ echo                           each stack frame, and also 
annotates each
 echo                           frame with a lambda or M to indicate whether
 echo                           it is a normal function call or a
 echo                           macro/special form.
+echo.
+echo --stale-file-error      Fail the test run if stale .elc files are loaded.
 exit /b
 
 :parse_args
@@ -110,6 +124,15 @@ if not [%current_arg%]==[] (
   ) else if !current_arg!==--no-color (
     set buttercup_args=!buttercup_args! !current_arg!
     shift /1
+  ) else if !current_arg!==--no-skip (
+    set buttercup_args=!buttercup_args! !current_arg!
+    shift /1
+  ) else if !current_arg!==--only-error (
+    set buttercup_args=!buttercup_args! !current_arg!
+    shift /1
+  ) else if !current_arg!==--stale-file-error (
+    set buttercup_args=!buttercup_args! !current_arg!
+    shift /1
   ) else if !current_arg!==--traceback (
     set buttercup_args=!buttercup_args! !current_arg! !next_arg!
     shift /1
diff --git a/buttercup.el b/buttercup.el
index 435fead..3b2154a 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1399,21 +1399,28 @@ current directory."
         (when (not (string-match "\\(^\\|/\\)\\." (file-relative-name file)))
           (load file nil t))))
     (when patterns
-      (buttercup-mark-skipped (regexp-opt patterns) t))
+      (buttercup-mark-skipped patterns t))
     (buttercup-run)))
 
 (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."
+MATCHER can be either a regex, a list of regexes, 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))))
+    (function (buttercup--mark-skipped buttercup-suites matcher reverse))
+    (list (cond
+           ((cl-every #'stringp matcher)
+            (buttercup-mark-skipped (mapconcat (lambda (re)
+                                                 (concat "\\(?:" re "\\)"))
+                                               matcher "\\|")
+                                    reverse))
+           (t (error "Bad matcher list: %s, should be list of strings" 
matcher))))))
 
 (defun buttercup--mark-skipped (suites predicate &optional reverse-predicate)
   "Mark all specs in SUITES as skipped if PREDICATE(spec) is true.
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index b9fbf54..cdf493a 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1549,7 +1549,7 @@ text properties using `ansi-color-apply'."
     (expect (buttercup-suites-total-specs-pending suites) :to-equal 11))
   (it "should handle multiple patterns"
     (with-local-buttercup :suites suites
-      (buttercup-mark-skipped (regexp-opt '("1-1-1" "1-1-2" "1-4" "2-4")) t))
+      (buttercup-mark-skipped '("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"
@@ -1567,7 +1567,9 @@ text properties using `ansi-color-apply'."
     (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)))
+      (expect (buttercup-mark-skipped 4) :to-throw))
+    (with-local-buttercup
+      (expect (buttercup-mark-skipped (list "re" "re" 5 "re")) :to-throw)))
   )
 
 ;;;;;;;;;;;;;;;;;;;;;



reply via email to

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