Skip to content

Commit ee47bfe

Browse files
committed
Fix double description prints when skipped statuses are enabled
The spec descriptions would be printed twice when buttercup-reporter-batch-quiet-statuses is non-empty.
1 parent faf8921 commit ee47bfe

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

buttercup.el

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,13 +1848,20 @@ EVENT and ARG are described in `buttercup-reporter'."
18481848
(when (buttercup--reporter-batch-preprint-spec-p arg)
18491849
(buttercup--print "%s" (buttercup--indented-description arg))))
18501850
(`spec-done
1851+
;; When printing has been held back but we will print the
1852+
;; result of this spec, print the all of the containing suite
1853+
;; descriptions that have been held back
18511854
(when (and buttercup-reporter-batch-quiet-statuses
18521855
(not (buttercup-reporter-batch--quiet-spec-p arg)))
18531856
(dolist (suite (nreverse buttercup-reporter-batch--suite-stack))
18541857
(buttercup--print "%s\n" (buttercup--indented-description suite)))
18551858
(setq buttercup-reporter-batch--suite-stack nil)
1856-
(buttercup--print "%s" (buttercup--indented-description arg)))
1859+
;; Also print the spec description unless it should not be preprinted
1860+
(unless (buttercup--reporter-batch-preprint-spec-p arg)
1861+
(buttercup--print "%s" (buttercup--indented-description arg))))
18571862

1863+
;; print the result of the spec. This should erase any
1864+
;; non-colored spec text.
18581865
(unless (buttercup-reporter-batch--quiet-spec-p arg)
18591866
(buttercup-reporter-batch--print-spec-done-line arg buttercup-color))
18601867

@@ -1914,11 +1921,14 @@ Finally print the elapsed time for SPEC."
19141921
(`failed 'red)
19151922
(`skipped nil))))
19161923
(when color
1917-
;; Carriage returns (\r) should not be colorized. It would mess
1918-
;; up color handling in Emacs compilation buffers using
1919-
;; `ansi-color-apply-on-region' in `compilation-filter-hook'.
1920-
(buttercup--print "%s%s"
1921-
(if (buttercup--reporter-batch-preprint-spec-p spec) "\r" "")
1924+
;; Clear the line if
1925+
(when (or buttercup-reporter-batch-quiet-statuses
1926+
(buttercup--reporter-batch-preprint-spec-p spec))
1927+
;; Carriage returns (\r) should not be colorized. It would mess
1928+
;; up color handling in Emacs compilation buffers using
1929+
;; `ansi-color-apply-on-region' in `compilation-filter-hook'.
1930+
(buttercup--print "\r"))
1931+
(buttercup--print "%s"
19221932
(buttercup-colorize
19231933
(buttercup--indented-description spec) color)))
19241934
(unless (eq 'passed status)

0 commit comments

Comments
 (0)