From afd3db17a01fd2fa8b2d1b85edcae389b3e7f647 Mon Sep 17 00:00:00 2001 From: antirez Date: Sun, 23 Feb 2014 17:57:53 +0100 Subject: [PATCH] Sentinel test: --pause-on-error option added. Pause the test with running instances available for state inspection on error. --- tests/sentinel.tcl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/sentinel.tcl b/tests/sentinel.tcl index f1c1669a..f06ade07 100644 --- a/tests/sentinel.tcl +++ b/tests/sentinel.tcl @@ -11,6 +11,7 @@ source tests/support/server.tcl source tests/support/test.tcl set ::verbose 0 +set ::pause_on_error 0 set ::sentinel_instances {} set ::redis_instances {} set ::sentinel_base_port 20000 @@ -95,10 +96,13 @@ proc parse_options {} { if {$opt eq "--single"} { incr j set ::run_matching "*${val}*" + } elseif {$opt eq "--pause-on-error"} { + set ::pause_on_error 1 } elseif {$opt eq "--help"} { puts "Hello, I'm sentinel.tcl and I run Sentinel unit tests." puts "\nOptions:" puts "--single Only runs tests specified by pattern." + puts "--pause-on-error Pause for manual inspection on error." puts "--help Shows this help." exit 0 } else { @@ -116,6 +120,18 @@ proc main {} { cleanup } +# If --pause-on-error option was passed at startup this function is called +# on error in order to give the developer a chance to understand more about +# the error condition while the instances are still running. +proc pause_on_error {} { + puts [colorstr yellow "*** Please inspect the error now ***"] + puts "\nType \"continue\" to resume the test." + while {[gets stdin] ne {continue}} { + puts "> " + flush stdout + } +} + # We redefine 'test' as for Sentinel we don't use the server-client # architecture for the test, everything is sequential. proc test {descr code} { @@ -126,6 +142,7 @@ proc test {descr code} { if {[string match "assertion:*" $error]} { set msg [string range $error 10 end] puts [colorstr red $msg] + if {$::pause_on_error} pause_on_error } else { # Re-raise, let handler up the stack take care of this. error $error $::errorInfo