From: antirez Date: Fri, 10 Dec 2010 16:24:03 +0000 (+0100) Subject: Merge remote branch 'pietern/testverbosity' X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/d6107fd6f194f568bd0fec3230cae83973de929d?hp=-c Merge remote branch 'pietern/testverbosity' --- d6107fd6f194f568bd0fec3230cae83973de929d diff --combined tests/support/server.tcl index 144bc2f5,39038bd6..4f48d22d --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@@ -83,9 -83,13 +83,13 @@@ proc ping_server {host port} } close $fd } e]} { - puts -nonewline "." + if {$::verbose} { + puts -nonewline "." + } } else { - puts -nonewline "ok" + if {$::verbose} { + puts -nonewline "ok" + } } return $retval } @@@ -171,7 -175,7 +175,7 @@@ proc start_server {options {code undefi set stderr [format "%s/%s" [dict get $config "dir"] "stderr"] if {$::valgrind} { - exec valgrind src/redis-server $config_file > $stdout 2> $stderr & + exec valgrind --suppressions=src/valgrind.sup src/redis-server $config_file > $stdout 2> $stderr & } else { exec src/redis-server $config_file > $stdout 2> $stderr & } @@@ -181,7 -185,10 +185,10 @@@ set retrynum 20 set serverisup 0 - puts -nonewline "=== ($tags) Starting server ${::host}:${::port} " + if {$::verbose} { + puts -nonewline "=== ($tags) Starting server ${::host}:${::port} " + } + after 10 if {$code ne "undefined"} { while {[incr retrynum -1]} { @@@ -196,7 -203,10 +203,10 @@@ } else { set serverisup 1 } - puts {} + + if {$::verbose} { + puts "" + } if {!$serverisup} { error_and_quit $config_file [exec cat $stderr] @@@ -246,41 -256,34 +256,34 @@@ reconnect # execute provided block - set curnum $::testnum - if {![catch { uplevel 1 $code } err]} { - # zero exit status is good - unset err + set num_tests $::num_tests + if {[catch { uplevel 1 $code } error]} { + set backtrace $::errorInfo + + # Kill the server without checking for leaks + dict set srv "skipleaks" 1 + kill_server $srv + + # Print warnings from log + puts [format "\nLogged warnings (pid %d):" [dict get $srv "pid"]] + set warnings [warnings_from_file [dict get $srv "stdout"]] + if {[string length $warnings] > 0} { + puts "$warnings" + } else { + puts "(none)" + } + puts "" + + error $error $backtrace } - if {$curnum == $::testnum} { - # don't check for leaks when no tests were executed + # Don't do the leak check when no tests were run + if {$num_tests == $::num_tests} { dict set srv "skipleaks" 1 } # pop the server object set ::servers [lrange $::servers 0 end-1] - - # allow an exception to bubble up the call chain but still kill this - # server, because we want to reuse the ports when the tests are re-run - if {[info exists err]} { - if {$err eq "exception"} { - puts [format "Logged warnings (pid %d):" [dict get $srv "pid"]] - set warnings [warnings_from_file [dict get $srv "stdout"]] - if {[string length $warnings] > 0} { - puts "$warnings" - } else { - puts "(none)" - } - # kill this server without checking for leaks - dict set srv "skipleaks" 1 - kill_server $srv - error "exception" - } elseif {[string length $err] > 0} { - puts "Error executing the suite, aborting..." - puts $err - exit 1 - } - } set ::tags [lrange $::tags 0 end-[llength $tags]] kill_server $srv diff --combined tests/test_helper.tcl index 82c4f91a,1852fa7b..2b7a8957 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@@ -13,13 -13,17 +13,17 @@@ set ::host 127.0.0. set ::port 16379 set ::traceleaks 0 set ::valgrind 0 + set ::verbose 0 set ::denytags {} set ::allowtags {} set ::external 0; # If "1" this means, we are running against external instance set ::file ""; # If set, runs only the tests in this comma separated list + set ::curfile ""; # Hold the filename of the current suite proc execute_tests name { - source "tests/$name.tcl" + set path "tests/$name.tcl" + set ::curfile $path + source $path } # Setup a list to hold a stack of server configs. When calls to start_server @@@ -147,9 -151,27 +151,27 @@@ proc main {} } cleanup - puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed" - if {$::failed > 0} { - puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n" + puts "\n[expr $::num_tests] tests, $::num_passed passed, $::num_failed failed\n" + if {$::num_failed > 0} { + set curheader "" + puts "Failures:" + foreach {test} $::tests_failed { + set header [lindex $test 0] + append header " (" + append header [join [lindex $test 1] ","] + append header ")" + + if {$curheader ne $header} { + set curheader $header + puts "\n$curheader:" + } + + set name [lindex $test 2] + set msg [lindex $test 3] + puts "- $name: $msg" + } + + puts "" exit 1 } } @@@ -167,8 -189,6 +189,8 @@@ for {set j 0} {$j < [llength $argv]} {i } } incr j + } elseif {$opt eq {--valgrind}} { + set ::valgrind 1 } elseif {$opt eq {--file}} { set ::file $arg incr j @@@ -179,6 -199,8 +201,8 @@@ } elseif {$opt eq {--port}} { set ::port $arg incr j + } elseif {$opt eq {--verbose}} { + set ::verbose 1 } else { puts "Wrong argument: $opt" exit 1 @@@ -189,7 -211,7 +213,7 @@@ if {[catch { main } err]} if {[string length $err] > 0} { # only display error when not generated by the test suite if {$err ne "exception"} { - puts $err + puts $::errorInfo } exit 1 }