]>
git.saurik.com Git - redis.git/blob - tests/test_helper.tcl
1 # Redis test suite. Copyright (C) 2009 Salvatore Sanfilippo antirez@gmail.com
2 # This softare is released under the BSD License. See the COPYING file for
6 source tests
/support
/redis.tcl
7 source tests
/support
/server.tcl
8 source tests
/support
/tmpfile.tcl
9 source tests
/support
/test.tcl
10 source tests
/support
/util.tcl
18 set ::external 0; # If "1" this means, we are running against external instance
19 set ::file ""; # If set, runs only the tests in this comma separated list
21 proc execute_tests name
{
22 source "tests/$name.tcl"
25 # Setup a list to hold a stack of server configs. When calls to start_server
26 # are nested, use "srv 0 pid" to get the pid of the inner server. To access
27 # outer servers, use "srv -1 pid" etcetera.
31 if {[string is integer
[lindex $args 0]]} {
32 set level
[lindex $args 0]
33 set property
[lindex $args 1]
35 set property
[lindex $args 0]
37 set srv
[lindex $::servers end
+$level]
38 dict get
$srv $property
41 # Provide easy access to the client for the inner server. It's possible to
42 # prepend the argument list with a negative level to access clients for
43 # servers running in outer blocks.
46 if {[string is integer
[lindex $args 0]]} {
47 set level
[lindex $args 0]
48 set args
[lrange $args 1 end
]
50 [srv
$level "client"] {*}$args
53 proc redis_deferring_client
{args
} {
55 if {[llength $args] > 0 && [string is integer
[lindex $args 0]]} {
56 set level
[lindex $args 0]
57 set args
[lrange $args 1 end
]
60 # create client that defers reading reply
61 set client
[redis
[srv
$level "host"] [srv
$level "port"] 1]
63 # select the right db and read the response (OK)
69 # Provide easy access to INFO properties. Same semantic as "proc r".
72 if {[string is integer
[lindex $args 0]]} {
73 set level
[lindex $args 0]
74 set args
[lrange $args 1 end
]
76 status
[srv
$level "client"] [lindex $args 0]
80 catch {exec rm
-rf {*}[glob tests
/tmp
/redis.conf.
*]}
81 catch {exec rm
-rf {*}[glob tests
/tmp
/server.
*]}
84 proc execute_everything
{} {
85 execute_tests
"unit/auth"
86 execute_tests
"unit/protocol"
87 execute_tests
"unit/basic"
88 execute_tests
"unit/type/list"
89 execute_tests
"unit/type/set"
90 execute_tests
"unit/type/zset"
91 execute_tests
"unit/type/hash"
92 execute_tests
"unit/sort"
93 execute_tests
"unit/expire"
94 execute_tests
"unit/other"
95 execute_tests
"unit/cas"
96 execute_tests
"integration/replication"
97 execute_tests
"integration/aof"
98 # execute_tests "integration/redis-cli"
99 execute_tests
"unit/pubsub"
101 # run tests with VM enabled
102 set ::global_overrides {vm-enabled yes
}
103 execute_tests
"unit/protocol"
104 execute_tests
"unit/basic"
105 execute_tests
"unit/type/list"
106 execute_tests
"unit/type/set"
107 execute_tests
"unit/type/zset"
108 execute_tests
"unit/type/hash"
109 execute_tests
"unit/sort"
110 execute_tests
"unit/expire"
111 execute_tests
"unit/other"
112 execute_tests
"unit/cas"
118 if {[string length
$::file] > 0} {
119 foreach {file} [split $::file ,] {
127 puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed"
129 puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n"
135 for {set j
0} {$j < [llength $argv]} {incr j
} {
136 set opt
[lindex $argv $j]
137 set arg
[lindex $argv [expr $j+1]]
138 if {$opt eq
{--tags}} {
140 if {[string index
$tag 0] eq
"-"} {
141 lappend ::denytags [string range
$tag 1 end
]
143 lappend ::allowtags $tag
147 } elseif
{$opt eq
{--file}} {
150 } elseif
{$opt eq
{--host}} {
154 } elseif
{$opt eq
{--port}} {
158 puts "Wrong argument: $opt"
163 if {[catch { main
} err
]} {
164 if {[string length
$err] > 0} {
165 # only display error when not generated by the test suite
166 if {$err ne
"exception"} {