colorize
* tool/generic_erb.rb: use VT100 sequence if tput does not work. * tool/ifchange: ditto and add --color option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
35957b7690
commit
be8a9db524
@ -24,8 +24,8 @@ end
|
|||||||
unchanged = "unchanged"
|
unchanged = "unchanged"
|
||||||
updated = "updated"
|
updated = "updated"
|
||||||
if color or (color == nil && STDOUT.tty?)
|
if color or (color == nil && STDOUT.tty?)
|
||||||
if (/\A(\e\[).*m\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
|
if (/\A(?:\e\[.*m|)\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
|
||||||
beg = $1
|
beg = "\e["
|
||||||
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
||||||
reset = "#{beg}m"
|
reset = "#{beg}m"
|
||||||
unchanged = "#{beg}#{colors["pass"] || "32;1"}m#{unchanged}#{reset}"
|
unchanged = "#{beg}#{colors["pass"] || "32;1"}m#{unchanged}#{reset}"
|
||||||
|
@ -5,6 +5,7 @@ set -e
|
|||||||
timestamp=
|
timestamp=
|
||||||
keepsuffix=
|
keepsuffix=
|
||||||
empty=
|
empty=
|
||||||
|
color=auto
|
||||||
until [ $# -eq 0 ]; do
|
until [ $# -eq 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--timestamp)
|
--timestamp)
|
||||||
@ -22,6 +23,12 @@ until [ $# -eq 0 ]; do
|
|||||||
--empty)
|
--empty)
|
||||||
empty=yes
|
empty=yes
|
||||||
;;
|
;;
|
||||||
|
--color)
|
||||||
|
color=always
|
||||||
|
;;
|
||||||
|
--color=*)
|
||||||
|
color=`expr \( "$1" : '[^=]*=\(.*\)' \)`
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@ -38,11 +45,10 @@ if [ "$temp" = - ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
msg_begin= msg_unchanged= msg_updated= msg_reset=
|
msg_begin= msg_unchanged= msg_updated= msg_reset=
|
||||||
if [ -t 1 ]; then
|
if [ "$color" = always -o \( "$color" = auto -a -t 1 \) ]; then
|
||||||
msg_begin="`tput smso 2>/dev/null`" || :
|
msg_begin="["
|
||||||
case "$msg_begin" in
|
case "`tput smso 2>/dev/null`" in
|
||||||
""*m)
|
"$msg_begin"*m|"")
|
||||||
msg_begin="`echo "$msg_begin" | sed 's/[0-9]*m$//'`"
|
|
||||||
if [ ${TEST_COLORS:+set} ]; then
|
if [ ${TEST_COLORS:+set} ]; then
|
||||||
msg_unchanged=`expr ":$TEST_COLORS:" : ".*:pass=\([^:]*\):"`
|
msg_unchanged=`expr ":$TEST_COLORS:" : ".*:pass=\([^:]*\):"`
|
||||||
msg_updated=`expr ":$TEST_COLORS:" : ".*:fail=\([^:]*\):"`
|
msg_updated=`expr ":$TEST_COLORS:" : ".*:fail=\([^:]*\):"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user