mirror of
https://github.com/fluencelabs/redis
synced 2025-06-28 16:31:33 +00:00
Testing framework fixes and improvements backported from 2.6.
This commit is contained in:
@ -3,6 +3,10 @@ set ::num_passed 0
|
||||
set ::num_failed 0
|
||||
set ::tests_failed {}
|
||||
|
||||
proc fail {msg} {
|
||||
error "assertion:$msg"
|
||||
}
|
||||
|
||||
proc assert {condition} {
|
||||
if {![uplevel 1 [list expr $condition]]} {
|
||||
error "assertion:Expected condition '$condition' to be true ([uplevel 1 [list subst -nocommands $condition]])"
|
||||
@ -44,6 +48,19 @@ proc assert_type {type key} {
|
||||
assert_equal $type [r type $key]
|
||||
}
|
||||
|
||||
# Wait for the specified condition to be true, with the specified number of
|
||||
# max retries and delay between retries. Otherwise the 'elsescript' is
|
||||
# executed.
|
||||
proc wait_for_condition {maxtries delay e _else_ elsescript} {
|
||||
while {[incr maxtries -1] >= 0} {
|
||||
if {[uplevel 1 [list expr $e]]} break
|
||||
after $delay
|
||||
}
|
||||
if {$maxtries == -1} {
|
||||
uplevel 1 $elsescript
|
||||
}
|
||||
}
|
||||
|
||||
# Test if TERM looks like to support colors
|
||||
proc color_term {} {
|
||||
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
|
||||
|
Reference in New Issue
Block a user