Skip to content

Commit

Permalink
Avoid printing double lines in GitHub Actions
Browse files Browse the repository at this point in the history
The "terminal" used in github action does not support the use of
carriage return '\r' to move back to column zero and overwrite the
line.  Carriage return will instead move to the next line.
The consequence was that each spec description was printed twice, once
without color before the spec was run and once with color once the
spec had run and the result was known.
Reuse the same mechanism as for specs with descriptions containing
newlines, don't print the spec description before running it unless
color is disabled.

Fixes jorgenschaefer#181.
  • Loading branch information
snogge committed Mar 21, 2024
1 parent afbb929 commit 2f3e034
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,8 @@ EVENT and ARG are described in `buttercup-reporter'."
(buttercup--print "%s\n" (buttercup--indented-description arg))))
(`spec-started
(or buttercup-reporter-batch-quiet-statuses
;; Do not 'pre-print' in github actions unless color is disabled. See #181.
(and (not buttercup-color) (getenv "GITHUB_ACTION"))
(and buttercup-color
(string-match-p "[\n\v\f]" (buttercup-spec-description arg)))
(buttercup--print "%s" (buttercup--indented-description arg))))
Expand Down Expand Up @@ -1883,7 +1885,7 @@ EVENT and ARG are described in `buttercup-reporter'."
(defun buttercup-reporter-batch--print-spec-done-line (spec color)
"Print the remainder of the SPEC report line for `spec-done'.
If COLOR is non-nil, erace the text so far on the current line
If COLOR is non-nil, erase the text so far on the current line
using '\\r' and replace it with the same text colored according to
the SPEC status. Do not erase and replace if the text would have
been reprinted with the default color.
Expand Down

0 comments on commit 2f3e034

Please sign in to comment.