Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
75d675d9
Commit
75d675d9
authored
Jul 12, 2010
by
Pieter Noordhuis
Browse files
partial cherry-pick of
d4507ec6
to import assertion functions
parent
243b914b
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/support/test.tcl
View file @
75d675d9
...
@@ -2,7 +2,38 @@ set ::passed 0
...
@@ -2,7 +2,38 @@ set ::passed 0
set ::failed 0
set ::failed 0
set ::testnum 0
set ::testnum 0
proc test
{
name code okpattern
}
{
proc assert_match
{
pattern value
}
{
if
{
!
[
string match $pattern $value
]}
{
puts
"!! ERROR
\n
Expected '
$value
' to match '
$pattern
'"
error
"assertion"
}
}
proc assert_equal
{
expected value
}
{
if
{
$expected
ne $value
}
{
puts
"!! ERROR
\n
Expected '
$value
' to be equal to '
$expected
'"
error
"assertion"
}
}
proc assert_error
{
pattern code
}
{
if
{[
catch $code error
]}
{
assert_match $pattern $error
}
else
{
puts
"!! ERROR
\n
Expected an error but nothing was catched"
error
"assertion"
}
}
proc assert_encoding
{
enc key
}
{
assert_match
"* encoding:
$enc
*"
[
r debug object $key
]
}
proc assert_type
{
type key
}
{
assert_equal $type
[
r type $key
]
}
proc test
{
name code
{
okpattern notspecified
}}
{
# abort if tagged with a tag to deny
# abort if tagged with a tag to deny
foreach tag $::denytags
{
foreach tag $::denytags
{
if
{[
lsearch $::tags $tag
]
>= 0
}
{
if
{[
lsearch $::tags $tag
]
>= 0
}
{
...
@@ -28,17 +59,22 @@ proc test {name code okpattern} {
...
@@ -28,17 +59,22 @@ proc test {name code okpattern} {
puts -nonewline
[
format
"#%03d %-68s "
$::testnum $name
]
puts -nonewline
[
format
"#%03d %-68s "
$::testnum $name
]
flush stdout
flush stdout
if
{[
catch
{
set retval
[
uplevel 1 $code
]}
error
]}
{
if
{[
catch
{
set retval
[
uplevel 1 $code
]}
error
]}
{
if
{
$error
eq
"assertion"
}
{
incr ::failed
}
else
{
puts
"EXCEPTION"
puts
"EXCEPTION"
puts
"
\n
Caught error:
$error
"
puts
"
\n
Caught error:
$error
"
error
"exception"
error
"exception"
}
}
if
{
$okpattern
eq $retval ||
[
string match $okpattern $retval
]}
{
}
else
{
if
{
$okpattern
eq
"notspecified"
|| $okpattern eq $retval ||
[
string match $okpattern $retval
]}
{
puts
"PASSED"
puts
"PASSED"
incr ::passed
incr ::passed
}
else
{
}
else
{
puts
"!! ERROR expected
\n
'
$okpattern
'
\n
but got
\n
'
$retval
'"
puts
"!! ERROR expected
\n
'
$okpattern
'
\n
but got
\n
'
$retval
'"
incr ::failed
incr ::failed
}
}
}
if
{
$::traceleaks
}
{
if
{
$::traceleaks
}
{
if
{
!
[
string match
{
*0 leaks*
}
[
exec leaks redis-server
]]}
{
if
{
!
[
string match
{
*0 leaks*
}
[
exec leaks redis-server
]]}
{
puts
"--------- Test
$::testnum
LEAKED! --------"
puts
"--------- Test
$::testnum
LEAKED! --------"
...
...
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