File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ proc main {} {
17
17
}
18
18
run_tests
19
19
cleanup
20
+ end_tests
20
21
}
21
22
22
23
if {[catch main e]} {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ set ::verbose 0
19
19
set ::valgrind 0
20
20
set ::pause_on_error 0
21
21
set ::simulate_error 0
22
+ set ::failed 0
22
23
set ::sentinel_instances {}
23
24
set ::redis_instances {}
24
25
set ::sentinel_base_port 20000
@@ -231,6 +232,7 @@ proc test {descr code} {
231
232
flush stdout
232
233
233
234
if {[catch {set retval [uplevel 1 $code ]} error]} {
235
+ incr ::failed
234
236
if {[string match " assertion:*" $error ]} {
235
237
set msg [string range $error 10 end]
236
238
puts [colorstr red $msg ]
@@ -246,6 +248,7 @@ proc test {descr code} {
246
248
}
247
249
}
248
250
251
+ # Execute all the units inside the 'tests' directory.
249
252
proc run_tests {} {
250
253
set tests [lsort [glob ../tests/*]]
251
254
foreach test $tests {
@@ -258,6 +261,17 @@ proc run_tests {} {
258
261
}
259
262
}
260
263
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
+
261
275
# The "S" command is used to interact with the N-th Sentinel.
262
276
# The general form is:
263
277
#
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ proc main {} {
13
13
spawn_instance redis $::redis_base_port $::instances_count
14
14
run_tests
15
15
cleanup
16
+ end_tests
16
17
}
17
18
18
19
if {[catch main e]} {
You can’t perform that action at this time.
0 commit comments