set ::failed 0
set ::testnum 0
+proc assert {condition} {
+ if {![uplevel 1 expr $condition]} {
+ puts "!! ERROR\nExpected '$value' to evaluate to true"
+ error "assertion"
+ }
+}
+
proc assert_match {pattern value} {
if {![string match $pattern $value]} {
puts "!! ERROR\nExpected '$value' to match '$pattern'"
}
proc assert_error {pattern code} {
- if {[catch $code error]} {
+ if {[catch {uplevel 1 $code} error]} {
assert_match $pattern $error
} else {
puts "!! ERROR\nExpected an error but nothing was catched"
}
proc assert_encoding {enc key} {
- assert_match "* encoding:$enc *" [r debug object $key]
+ # Swapped out values don't have an encoding, so make sure that
+ # the value is swapped in before checking the encoding.
+ set dbg [r debug object $key]
+ while {[string match "* swapped at:*" $dbg]} {
+ r debug swapin $key
+ set dbg [r debug object $key]
+ }
+ assert_match "* encoding:$enc *" $dbg
}
proc assert_type {type key} {
}
}
if {$::traceleaks} {
- if {![string match {*0 leaks*} [exec leaks redis-server]]} {
+ set output [exec leaks redis-server]
+ if {![string match {*0 leaks*} $output]} {
puts "--------- Test $::testnum LEAKED! --------"
+ puts $output
exit 1
}
}