]> git.saurik.com Git - redis.git/blob - tests/support/test.tcl
generic pop and length function for ziplist encoding
[redis.git] / tests / support / test.tcl
1 set ::passed 0
2 set ::failed 0
3 set ::testnum 0
4
5 proc test {name code okpattern} {
6 incr ::testnum
7 # if {$::testnum < $::first || $::testnum > $::last} return
8 puts -nonewline [format "#%03d %-68s " $::testnum $name]
9 flush stdout
10 if {[catch {set retval [uplevel 1 $code]} error]} {
11 puts "ERROR\n\nLogged warnings:"
12 foreach file [glob tests/tmp/server.[pid].*/stdout] {
13 set warnings [warnings_from_file $file]
14 if {[string length $warnings] > 0} {
15 puts $warnings
16 }
17 }
18 puts "Script died with $error"
19 exit 1
20 }
21 if {$okpattern eq $retval || [string match $okpattern $retval]} {
22 puts "PASSED"
23 incr ::passed
24 } else {
25 puts "!! ERROR expected\n'$okpattern'\nbut got\n'$retval'"
26 incr ::failed
27 }
28 if {$::traceleaks} {
29 if {![string match {*0 leaks*} [exec leaks redis-server]]} {
30 puts "--------- Test $::testnum LEAKED! --------"
31 exit 1
32 }
33 }
34 }