From: Pieter Noordhuis Date: Wed, 2 Jun 2010 20:23:52 +0000 (+0200) Subject: changed how server.tcl accepts options to support more directives without requiring... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/9e5d2e8bd664743d309f1647e29cdaf43f463051?hp=38273a9ed6a92f5a9c0c6250484fff677b972019 changed how server.tcl accepts options to support more directives without requiring more arguments to the proc --- diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 0d933449..ea2b399a 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -17,7 +17,7 @@ proc create_aof {code} { proc start_server_aof {overrides code} { upvar defaults defaults srv srv server_path server_path set _defaults $defaults - set srv [start_server default.conf [lappend _defaults $overrides]] + set srv [start_server {overrides [lappend _defaults $overrides]}] uplevel 1 $code kill_server $srv } diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 6a97edf4..0f61b751 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -1,7 +1,7 @@ -start_server default.conf {} { +start_server {} { r set mykey foo - start_server default.conf {} { + start_server {} { test {Second server should have role master at first} { s role } {master} diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 750d799a..419267b4 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -81,8 +81,21 @@ proc ping_server {host port} { } set ::global_overrides {} -proc start_server {filename overrides {code undefined}} { - set data [split [exec cat "tests/assets/$filename"] "\n"] +proc start_server {options {code undefined}} { + # setup defaults + set baseconfig "default.conf" + set overrides {} + + # parse options + foreach {option value} $options { + switch $option { + "config" { set baseconfig $value } + "overrides" { set overrides $value } + default { error "Unknown option $option" } + } + } + + set data [split [exec cat "tests/assets/$baseconfig"] "\n"] set config {} foreach line $data { if {[string length $line] > 0 && [string index $line 0] ne "#"} { @@ -100,9 +113,7 @@ proc start_server {filename overrides {code undefined}} { dict set config port [incr ::port] # apply overrides from global space and arguments - foreach override [concat $::global_overrides $overrides] { - set directive [lrange $override 0 0] - set arguments [lrange $override 1 end] + foreach {directive arguments} [concat $::global_overrides $overrides] { dict set config $directive $arguments } diff --git a/tests/unit/auth.tcl b/tests/unit/auth.tcl index 5bc83de8..a10358ce 100644 --- a/tests/unit/auth.tcl +++ b/tests/unit/auth.tcl @@ -1,4 +1,4 @@ -start_server default.conf {{requirepass foobar}} { +start_server {overrides {requirepass foobar}} { test {AUTH fails when a wrong password is given} { catch {r auth wrong!} err format $err diff --git a/tests/unit/basic.tcl b/tests/unit/basic.tcl index b14ac6ed..edde91c4 100644 --- a/tests/unit/basic.tcl +++ b/tests/unit/basic.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {DEL all keys to start with a clean DB} { foreach key [r keys *] {r del $key} r dbsize diff --git a/tests/unit/cas.tcl b/tests/unit/cas.tcl index b8506796..febc7d6b 100644 --- a/tests/unit/cas.tcl +++ b/tests/unit/cas.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {EXEC works on WATCHed key not modified} { r watch x y z r watch k diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 5954194c..c0dc8b94 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {EXPIRE - don't set timeouts multiple times} { r set x foobar set v1 [r expire x 5] diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index 4d42c436..00d2dd46 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {SAVE - make sure there are all the types as values} { # Wait for a background saving in progress to terminate waitForBgsave r diff --git a/tests/unit/protocol.tcl b/tests/unit/protocol.tcl index 28334e30..8717cd9f 100644 --- a/tests/unit/protocol.tcl +++ b/tests/unit/protocol.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {Handle an empty query well} { set fd [r channel] puts -nonewline $fd "\r\n" diff --git a/tests/unit/sort.tcl b/tests/unit/sort.tcl index 2985c3d9..6ae62cf7 100644 --- a/tests/unit/sort.tcl +++ b/tests/unit/sort.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {SORT ALPHA against integer encoded strings} { r del mylist r lpush mylist 2 diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 0d08cc55..fd44c0b8 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {HSET/HLEN - Small hash creation} { array set smallhash {} for {set i 0} {$i < 8} {incr i} { diff --git a/tests/unit/type/list.tcl b/tests/unit/type/list.tcl index 2597f1b9..6b1a39a2 100644 --- a/tests/unit/type/list.tcl +++ b/tests/unit/type/list.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {Basic LPUSH, RPUSH, LLENGTH, LINDEX} { set res [r lpush mylist a] append res [r lpush mylist b] diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl index c8d1a695..c69f8ece 100644 --- a/tests/unit/type/set.tcl +++ b/tests/unit/type/set.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {SADD, SCARD, SISMEMBER, SMEMBERS basics} { r sadd myset foo r sadd myset bar diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 9eb61f25..0bdefeae 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -1,4 +1,4 @@ -start_server default.conf {} { +start_server {} { test {ZSET basic ZADD and score update} { r zadd ztmp 10 x r zadd ztmp 20 y