[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup e71a40f 287/340: Make sure carriage movement cha
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup e71a40f 287/340: Make sure carriage movement characters are not colorized |
Date: |
Thu, 16 Dec 2021 14:59:52 -0500 (EST) |
branch: elpa/buttercup
commit e71a40f1ffef4847df28c9d4ad7edc1e360ee52a
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Make sure carriage movement characters are not colorized
Fixes #171, which reports that adding `ansi-color-apply-on-region' to
`compilation-filter-hook' did not work with colorized buttercup
output. This was because in the `compilation-filter' function,
carriage movement characters '\r' and '\n' are handled (by
`comint-carriage-motion') before `compilation-filter-hook'.
It is often recommended to use
;; either `point' or `point-max' work as the second argument
(ansi-color-apply-on-region compilation-filter-start (point))
in a `compilation-filter-hook' function to handle ANSI or SGR control
sequences in compilation output. But carriage motion may cause
`point' to move to before `compilation-filter-start'. Then
`ansi-color-apply-on-region' will miss SGR control sequences in the
`point' - `compilation-filter-start' range. Using
(ansi-color-apply-on-region
(save-excursion
(goto-char compilation-filter-start)
(line-beginning-position))
(point))))
instead will at least avoid this problem for carriage motion that does
not move point to preceding lines.
---
buttercup.el | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index eeaf5d3..bbbf3fc 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1504,8 +1504,18 @@ Do not change the global value.")
(with-current-buffer buttercup-warning-buffer-name
(when (string-match-p "[^[:space:]\n\r]" (buffer-string))
(buttercup--print
+ "%s\n"
(buttercup-colorize
- (buffer-string)
+ ;; Any terminating newline in the buffer should not be
+ ;; colorized. It would mess up color handling in Emacs
+ ;; compilation buffers using
+ ;; `ansi-color-apply-on-region' in
+ ;; `compilation-filter-hook'.
+ (buffer-substring (point-min)
+ (save-excursion
+ (goto-char (1- (point-max)))
+ (if (looking-at-p "\n")
+ (point) (point-max))))
'yellow)))))
(when (get-buffer buttercup-warning-buffer-name)
(kill-buffer buttercup-warning-buffer-name))
@@ -1653,22 +1663,29 @@ EVENT and ARG are described in `buttercup-reporter'."
(unless (string-match-p "[\n\v\f]" (buttercup-spec-description arg))
(buttercup-reporter-batch event arg)))
(`spec-done
+ ;; Carriage returns (\r) should not be colorized. It would mess
+ ;; up color handling in Emacs compilation buffers using
+ ;; `ansi-color-apply-on-region' in `compilation-filter-hook'.
(pcase (buttercup-spec-status arg)
(`passed
- (buttercup--print (buttercup-colorize "\r%s" 'green)
- (buttercup--indented-description arg)))
+ (buttercup--print
+ "\r%s" (buttercup-colorize (buttercup--indented-description arg)
'green)))
(`failed
- (buttercup--print (buttercup-colorize "\r%s FAILED" 'red)
- (buttercup--indented-description arg))
+ (buttercup--print
+ "\r%s" (buttercup-colorize
+ (concat (buttercup--indented-description arg) " FAILED")
+ 'red))
(setq buttercup-reporter-batch--failures
(append buttercup-reporter-batch--failures
(list arg))))
(`pending
(if (equal (buttercup-spec-failure-description arg) "SKIPPED")
(buttercup--print " %s" (buttercup-spec-failure-description arg))
- (buttercup--print (buttercup-colorize "\r%s %s" 'yellow)
- (buttercup--indented-description arg)
- (buttercup-spec-failure-description arg))))
+ (buttercup--print
+ "\r%s" (buttercup-colorize
+ (concat (buttercup--indented-description arg) " "
+ (buttercup-spec-failure-description arg))
+ 'yellow))))
(_
(error "Unknown spec status %s" (buttercup-spec-status arg))))
(buttercup--print " (%s)\n" (buttercup-elapsed-time-string arg)))
@@ -1780,7 +1797,7 @@ the capturing behavior."
(defun buttercup-colorize (string color)
"Format STRING with COLOR."
(let ((color-code (cdr (assoc color buttercup-colors))))
- (format "\u001b[%sm%s\u001b[0m" color-code string)))
+ (format "\e[%sm%s\e[0m" color-code string)))
(defun buttercup-reporter-interactive (event arg)
"Reporter for interactive sessions.
- [nongnu] elpa/buttercup fc4276a 247/340: Make it possible to abort test run cleanly, (continued)
- [nongnu] elpa/buttercup fc4276a 247/340: Make it possible to abort test run cleanly, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dbcd3d4 256/340: Calculate total test run time with current-time, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c83ba7d 268/340: Extract function buttercup-elapsed-time-string, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 38cfa6f 270/340: Fix spy-on on Emacs 24.3 for symbols that are not fbound, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 81bfed4 272/340: test: Add utility function send-string-to-ansi-buffer, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The batch reporter" suite, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4159111 275/340: test: Verify full line for reporter spec-done tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fbb790b 278/340: test: Add tests for buttercup-started and buttercup-reporter-batch-color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d563e18 281/340: test: Add color tests for suite-done, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b910b71 285/340: Extract buttercup--indented-description from the batch reporters, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e71a40f 287/340: Make sure carriage movement characters are not colorized,
ELPA Syncer <=
- [nongnu] elpa/buttercup a22fc29 288/340: Bump version: 1.21 → 1.22, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dde8651 290/340: Add new function buttercup--spec-mark-pending and use it, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c59110b 291/340: test: Extend with-local-buttercup with some key arguments, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d443ecb 293/340: Clarify patterns in bin/buttercup, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4d1acb8 294/340: test: Rewrite buttercup-run tests using spies, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 37223e4 296/340: actions: Run actions on push for all branches, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 50c7fc2 297/340: Switch to pcase in spec-done case of buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dd32cc7 298/340: test: Fix "should color-print pending spec count in default color", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0debeec 299/340: test: Use with-local-buttercup in more tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b3acf50 304/340: Lift spec-started handling into buttercup-reporter-batch, ELPA Syncer, 2021/12/16