Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3744824c
Commit
3744824c
authored
Jul 11, 2011
by
antirez
Browse files
some test colorization and some fix
parent
36e790a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/support/test.tcl
View file @
3744824c
...
@@ -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
}
}
}
}
}
...
...
tests/test_helper.tcl
View file @
3744824c
...
@@ -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
"
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment