Skip to content

Commit 6509040

Browse files
committed
Sentinel / Cluster test: exit with non-zero error code on failures.
1 parent 7f330b1 commit 6509040

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

tests/cluster/run.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ proc main {} {
1717
}
1818
run_tests
1919
cleanup
20+
end_tests
2021
}
2122

2223
if {[catch main e]} {

tests/instances.tcl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set ::verbose 0
1919
set ::valgrind 0
2020
set ::pause_on_error 0
2121
set ::simulate_error 0
22+
set ::failed 0
2223
set ::sentinel_instances {}
2324
set ::redis_instances {}
2425
set ::sentinel_base_port 20000
@@ -231,6 +232,7 @@ proc test {descr code} {
231232
flush stdout
232233

233234
if {[catch {set retval [uplevel 1 $code]} error]} {
235+
incr ::failed
234236
if {[string match "assertion:*" $error]} {
235237
set msg [string range $error 10 end]
236238
puts [colorstr red $msg]
@@ -246,6 +248,7 @@ proc test {descr code} {
246248
}
247249
}
248250

251+
# Execute all the units inside the 'tests' directory.
249252
proc run_tests {} {
250253
set tests [lsort [glob ../tests/*]]
251254
foreach test $tests {
@@ -258,6 +261,17 @@ proc run_tests {} {
258261
}
259262
}
260263

264+
# Print a message and exists with 0 / 1 according to zero or more failures.
265+
proc end_tests {} {
266+
if {$::failed == 0} {
267+
puts "GOOD! No errors."
268+
exit 0
269+
} else {
270+
puts "WARNING $::failed tests faield."
271+
exit 1
272+
}
273+
}
274+
261275
# The "S" command is used to interact with the N-th Sentinel.
262276
# The general form is:
263277
#

tests/sentinel/run.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ proc main {} {
1313
spawn_instance redis $::redis_base_port $::instances_count
1414
run_tests
1515
cleanup
16+
end_tests
1617
}
1718

1819
if {[catch main e]} {

0 commit comments

Comments
 (0)