From 93959bc09f21aea5b23c12fc8afe6758819a7af1 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 30 Mar 2015 14:29:01 +0200 Subject: [PATCH] Sentinel / Cluster test: exit with non-zero error code on failures. --- tests/cluster/run.tcl | 1 + tests/instances.tcl | 14 ++++++++++++++ tests/sentinel/run.tcl | 1 + 3 files changed, 16 insertions(+) diff --git a/tests/cluster/run.tcl b/tests/cluster/run.tcl index f764cea0..93603ddc 100644 --- a/tests/cluster/run.tcl +++ b/tests/cluster/run.tcl @@ -17,6 +17,7 @@ proc main {} { } run_tests cleanup + end_tests } if {[catch main e]} { diff --git a/tests/instances.tcl b/tests/instances.tcl index 353d9b2d..370d5e3a 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -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 @@ -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] @@ -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 { @@ -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: # diff --git a/tests/sentinel/run.tcl b/tests/sentinel/run.tcl index f3302995..9a2fcfb4 100644 --- a/tests/sentinel/run.tcl +++ b/tests/sentinel/run.tcl @@ -13,6 +13,7 @@ proc main {} { spawn_instance redis $::redis_base_port $::instances_count run_tests cleanup + end_tests } if {[catch main e]} { -- GitLab