]>
git.saurik.com Git - redis.git/blob - tests/support/test.tcl
5 proc assert_match
{pattern value
} {
6 if {![string match
$pattern $value]} {
7 puts "!! ERROR\nExpected '$value' to match '$pattern'"
12 proc assert_equal
{expected value
} {
13 if {$expected ne
$value} {
14 puts "!! ERROR\nExpected '$value' to be equal to '$expected'"
19 proc assert_error
{pattern code
} {
20 if {[catch $code error]} {
21 assert_match
$pattern $error
23 puts "!! ERROR\nExpected an error but nothing was catched"
28 proc assert_encoding
{enc key
} {
29 assert_match
"* encoding:$enc *" [r debug object
$key]
32 proc assert_type
{type key
} {
33 assert_equal
$type [r type
$key]
36 proc test
{name code
{okpattern notspecified
}} {
37 # abort if tagged with a tag to deny
38 foreach tag
$::denytags {
39 if {[lsearch $::tags $tag] >= 0} {
44 # check if tagged with at least 1 tag to allow when there *is* a list
45 # of tags to allow, because default policy is to run everything
46 if {[llength $::allowtags] > 0} {
48 foreach tag
$::allowtags {
49 if {[lsearch $::tags $tag] >= 0} {
59 puts -nonewline [format "#%03d %-68s " $::testnum $name]
61 if {[catch {set retval
[uplevel 1 $code]} error]} {
62 if {$error eq
"assertion"} {
66 puts "\nCaught error: $error"
70 if {$okpattern eq
"notspecified" ||
$okpattern eq
$retval ||
[string match
$okpattern $retval]} {
74 puts "!! ERROR expected\n'$okpattern'\nbut got\n'$retval'"
79 if {![string match
{*0 leaks
*} [exec leaks redis-server
]]} {
80 puts "--------- Test $::testnum LEAKED! --------"