diff --git a/redis.c b/redis.c index b5bbd04db..9e4a5dd3f 100644 --- a/redis.c +++ b/redis.c @@ -10556,7 +10556,7 @@ static void debugCommand(redisClient *c) { static void _redisAssert(char *estr, char *file, int line) { redisLog(REDIS_WARNING,"=== ASSERTION FAILED ==="); - redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true\n",file,line,estr); + redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true",file,line,estr); #ifdef HAVE_BACKTRACE redisLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)"); *((char*)-1) = 'x'; diff --git a/tests/support/test.tcl b/tests/support/test.tcl index c695c82fa..83985e3e1 100644 --- a/tests/support/test.tcl +++ b/tests/support/test.tcl @@ -7,7 +7,16 @@ proc test {name code okpattern} { # if {$::testnum < $::first || $::testnum > $::last} return puts -nonewline [format "#%03d %-68s " $::testnum $name] flush stdout - set retval [uplevel 1 $code] + if {[catch {set retval [uplevel 1 $code]} error]} { + puts "ERROR\n\nLogged warnings:" + foreach file [glob tests/tmp/server.[pid].*/stdout] { + set warnings [warnings_from_file $file] + if {[string length $warnings] > 0} { + puts $warnings + } + } + exit 1 + } if {$okpattern eq $retval || [string match $okpattern $retval]} { puts "PASSED" incr ::passed diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 8a7c3f1d8..09a5804c1 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -25,6 +25,23 @@ proc zlistAlikeSort {a b} { string compare [lindex $a 1] [lindex $b 1] } +# Return all log lines starting with the first line that contains a warning. +# Generally, this will be an assertion error with a stack trace. +proc warnings_from_file {filename} { + set lines [split [exec cat $filename] "\n"] + set matched 0 + set result {} + foreach line $lines { + if {[regexp {^\[\d+\]\s+\d+\s+\w+\s+\d{2}:\d{2}:\d{2} \#} $line]} { + set matched 1 + } + if {$matched} { + lappend result $line + } + } + join $result "\n" +} + # Return value for INFO property proc status {r property} { if {[regexp "\r\n$property:(.*?)\r\n" [$r info] _ value]} {