Skip to content

Commit

Permalink
Sentinel / Cluster test: exit with non-zero error code on failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Mar 30, 2015
1 parent 7f330b1 commit 6509040
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/cluster/run.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ proc main {} {
}
run_tests
cleanup
end_tests
}

if {[catch main e]} {
Expand Down
14 changes: 14 additions & 0 deletions tests/instances.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set ::verbose 0
set ::valgrind 0
set ::pause_on_error 0
set ::simulate_error 0
set ::failed 0
set ::sentinel_instances {}
set ::redis_instances {}
set ::sentinel_base_port 20000
Expand Down Expand Up @@ -231,6 +232,7 @@ proc test {descr code} {
flush stdout

if {[catch {set retval [uplevel 1 $code]} error]} {
incr ::failed
if {[string match "assertion:*" $error]} {
set msg [string range $error 10 end]
puts [colorstr red $msg]
Expand All @@ -246,6 +248,7 @@ proc test {descr code} {
}
}

# Execute all the units inside the 'tests' directory.
proc run_tests {} {
set tests [lsort [glob ../tests/*]]
foreach test $tests {
Expand All @@ -258,6 +261,17 @@ proc run_tests {} {
}
}

# Print a message and exists with 0 / 1 according to zero or more failures.
proc end_tests {} {
if {$::failed == 0} {
puts "GOOD! No errors."
exit 0
} else {
puts "WARNING $::failed tests faield."
exit 1
}
}

# The "S" command is used to interact with the N-th Sentinel.
# The general form is:
#
Expand Down
1 change: 1 addition & 0 deletions tests/sentinel/run.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ proc main {} {
spawn_instance redis $::redis_base_port $::instances_count
run_tests
cleanup
end_tests
}

if {[catch main e]} {
Expand Down

0 comments on commit 6509040

Please sign in to comment.