From 7d04fc75630387b2c02e8f9907cf8deda37d648a Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 14 Jun 2010 10:19:45 +0200 Subject: [PATCH] allow running the test suite against an external Redis instance, without auto spawning --- tests/support/server.tcl | 21 +++++++++++++++++++++ tests/test_helper.tcl | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 0c9f48ce9..eb5fe6214 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -25,6 +25,9 @@ proc check_valgrind_errors stderr { } proc kill_server config { + # nothing to kill when running against external server + if {$::external} return + # nevermind if its already dead if {![is_alive $config]} { return } set pid [dict get $config pid] @@ -93,6 +96,24 @@ proc tags {tags code} { } proc start_server {options {code undefined}} { + # If we are runnign against an external server, we just push the + # host/port pair in the stack the first time + if {$::external} { + if {[llength $::servers] == 0} { + set srv {} + dict set srv "host" $::host + dict set srv "port" $::port + set client [redis $::host $::port] + dict set srv "client" $client + $client select 9 + + # append the server to the stack + lappend ::servers $srv + } + uplevel 1 $code + return + } + # setup defaults set baseconfig "default.conf" set overrides {} diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 5aa242480..da6520a36 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -15,6 +15,7 @@ set ::traceleaks 0 set ::valgrind 0 set ::denytags {} set ::allowtags {} +set ::external 0; # If "1" this means, we are running against external instance proc execute_tests name { source "tests/$name.tcl" @@ -106,6 +107,13 @@ for {set j 0} {$j < [llength $argv]} {incr j} { } } incr j + } elseif {$opt eq {--host}} { + set ::external 1 + set ::host $arg + incr j + } elseif {$opt eq {--port}} { + set ::port $arg + incr j } else { puts "Wrong argument: $opt" exit 1