提交 3744824c 编写于 作者: A antirez

some test colorization and some fix

上级 36e790a0
...@@ -49,48 +49,22 @@ proc color_term {} { ...@@ -49,48 +49,22 @@ proc color_term {} {
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]} expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
} }
# This is called after the test finished proc colorstr {color str} {
proc colored_dot {tags passed} {
if {[color_term]} { if {[color_term]} {
# Go backward and delete what announc_test function printed. switch $color {
puts -nonewline "\033\[${::backward_count}D\033\[0K\033\[J" red {set colorcode {31}}
green {set colorcode {32}}
# Print a coloured char, accordingly to test outcome and tags. yellow {set colorcode {33}}
if {[lsearch $tags list] != -1} { blue {set colorcode {34}}
set colorcode {31} magenta {set colorcode {35}}
set ch L cyan {set colorcode {36}}
} elseif {[lsearch $tags hash] != -1} { else {set colorcode {37}}
set colorcode {32}
set ch H
} elseif {[lsearch $tags set] != -1} {
set colorcode {33}
set ch S
} elseif {[lsearch $tags zset] != -1} {
set colorcode {34}
set ch Z
} elseif {[lsearch $tags basic] != -1} {
set colorcode {35}
set ch B
} else {
set colorcode {37}
set ch .
} }
if {$colorcode ne {}} { if {$colorcode ne {}} {
if {$passed} { return "\033\[0;${colorcode};40m$str\033\[0m"
puts -nonewline "\033\[0;${colorcode};40m"
} else {
puts -nonewline "\033\[7;${colorcode};40m"
}
puts -nonewline $ch
puts -nonewline "\033\[0m"
flush stdout
} }
} else { } else {
if {$passed} { return $str
puts -nonewline .
} else {
puts -nonewline F
}
} }
} }
......
...@@ -209,14 +209,21 @@ proc read_from_test_client fd { ...@@ -209,14 +209,21 @@ proc read_from_test_client fd {
set bytes [gets $fd] set bytes [gets $fd]
set payload [read $fd $bytes] set payload [read $fd $bytes]
foreach {status data} $payload break foreach {status data} $payload break
puts "($fd) \[$status\]: $data"
if {$status eq {ready}} { if {$status eq {ready}} {
puts "($fd) \[$status\]: $data"
signal_idle_client $fd signal_idle_client $fd
} elseif {$status eq {done}} { } elseif {$status eq {done}} {
set elapsed [expr {[clock seconds]-$::clients_start_time($fd)}] set elapsed [expr {[clock seconds]-$::clients_start_time($fd)}]
puts "+++ [llength $::active_clients] units still in execution ($elapsed seconds)." puts "($fd) \[[colorstr yellow $status]\]: $data ($elapsed seconds)"
puts "+++ [llength $::active_clients] units still in execution."
lappend ::clients_time_history $elapsed $data lappend ::clients_time_history $elapsed $data
signal_idle_client $fd signal_idle_client $fd
} elseif {$status eq {ok}} {
puts "($fd) \[[colorstr green $status]\]: $data"
} elseif {$status eq {err}} {
puts "($fd) \[[colorstr red $status]\]: $data"
} else {
puts "($fd) \[$status\]: $data"
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册