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

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

[nongnu] elpa/buttercup a91f282 283/340: Handle multiline spec descripti


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup a91f282 283/340: Handle multiline spec descriptions in buttercup-reporter-batch-color
Date: Thu, 16 Dec 2021 14:59:51 -0500 (EST)

branch: elpa/buttercup
commit a91f2820256a4e0c8636cc33a2ef8515a26d3f81
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>

    Handle multiline spec descriptions in buttercup-reporter-batch-color
    
    The default way of printing the description in default color in
    spec-started and then using carriage return to re-print it in the
    status color does not work for multiline descriptions.  Avoid
    duplicate output by not printing in spec-started if the description
    contains a vertical movement control character.
    
    Fixes #138.
---
 buttercup.el            |  3 +++
 tests/test-buttercup.el | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/buttercup.el b/buttercup.el
index 1bbbf90..8449d87 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1651,6 +1651,9 @@ colors.
 
 EVENT and ARG are described in `buttercup-reporter'."
   (pcase event
+    (`spec-started
+     (unless (string-match-p "[\n\v\f]" (buttercup-spec-description arg))
+       (buttercup-reporter-batch event arg)))
     (`spec-done
      (let ((level (length (buttercup-suite-or-spec-parents arg))))
        (cond
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 9726184..025b419 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1158,6 +1158,23 @@ text properties using `ansi-color-apply'."
           (expect (buttercup-output) :to-equal-including-properties
                   (ansi-color-apply
                    (format "\e[32m    spec\e[0m (%s)\n"
+                           (buttercup-elapsed-time-string spec)))))
+
+        (it "should print multiline specs cleanly"
+          (setf (buttercup-spec-description spec) "one\ntwo\vthree")
+          (buttercup-reporter-batch 'spec-started spec)
+          (buttercup-reporter-batch 'spec-done spec)
+          (expect (buttercup-output) :to-equal-including-properties
+                  (format "    one\ntwo\n   three (%s)\n"
+                          (buttercup-elapsed-time-string spec))))
+
+        (it "should color-print multiline specs cleanly"
+          (setf (buttercup-spec-description spec) "one\ntwo\vthree")
+          (buttercup-reporter-batch-color 'spec-started spec)
+          (buttercup-reporter-batch-color 'spec-done spec)
+          (expect (buttercup-output) :to-equal-including-properties
+                  (ansi-color-apply
+                   (format "\e[32m    one\ntwo\n   three\e[0m (%s)\n"
                            (buttercup-elapsed-time-string spec))))))
 
       (describe "for a failed spec"



reply via email to

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