summaryrefslogtreecommitdiff
path: root/tests/support
diff options
context:
space:
mode:
authorValentino Geron <valentino@redislabs.com>2022-05-25 18:25:38 +0300
committerGitHub <noreply@github.com>2022-05-25 18:25:38 +0300
commit9eb97b5d94ca4434f9035af164fe3a48dca31de2 (patch)
tree9ad7ef3f4ec0462d35df0cb060f3f0e2b83a1478 /tests/support
parent450c88f368317ae9d2d3d597cf121999660e2934 (diff)
downloadredis-9eb97b5d94ca4434f9035af164fe3a48dca31de2.tar.gz
Fix regex support in --only, --skipfile and --skiptest (#10741)
The regex support was added in: * https://github.com/redis/redis/pull/9352 * https://github.com/redis/redis/pull/9555 * https://github.com/redis/redis/pull/10212 These commits break backword compatiblity with older versions. This fix keeps the test suite infra compatible with old versions by default. However, if you want regex, the string must start with `/`
Diffstat (limited to 'tests/support')
-rw-r--r--tests/support/test.tcl26
1 files changed, 17 insertions, 9 deletions
diff --git a/tests/support/test.tcl b/tests/support/test.tcl
index f5de12256..34b5aad29 100644
--- a/tests/support/test.tcl
+++ b/tests/support/test.tcl
@@ -126,28 +126,36 @@ proc wait_for_condition {maxtries delay e _else_ elsescript} {
}
}
-# try to match a value to a list of patterns that is either regex, or plain sub-string
-proc search_pattern_list {value pattern_list {substr false}} {
- set n 0
+# try to match a value to a list of patterns that are either regex (starts with "/") or plain string.
+# The caller can specify to use only glob-pattern match
+proc search_pattern_list {value pattern_list {glob_pattern false}} {
foreach el $pattern_list {
- if {[string length $el] > 0 && ((!$substr && [regexp -- $el $value]) || ($substr && [string match $el $value]))} {
- return $n
+ if {[string length $el] == 0} { continue }
+ if { $glob_pattern } {
+ if {[string match $el $value]} {
+ return 1
+ }
+ continue
+ }
+ if {[string equal / [string index $el 0]] && [regexp -- [string range $el 1 end] $value]} {
+ return 1
+ } elseif {[string equal $el $value]} {
+ return 1
}
- incr n
}
- return -1
+ return 0
}
proc test {name code {okpattern undefined} {tags {}}} {
# abort if test name in skiptests
- if {[search_pattern_list $name $::skiptests] >= 0} {
+ if {[search_pattern_list $name $::skiptests]} {
incr ::num_skipped
send_data_packet $::test_server_fd skip $name
return
}
# abort if only_tests was set but test name is not included
- if {[llength $::only_tests] > 0 && [search_pattern_list $name $::only_tests] < 0} {
+ if {[llength $::only_tests] > 0 && ![search_pattern_list $name $::only_tests]} {
incr ::num_skipped
send_data_packet $::test_server_fd skip $name
return