branch: elpa/buttercup
commit a91f2820256a4e0c8636cc33a2ef8515a26d3f81
Author: Ola Nilsson <[email protected]>
Commit: Ola Nilsson <[email protected]>
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"