From 9eb97b5d94ca4434f9035af164fe3a48dca31de2 Mon Sep 17 00:00:00 2001 From: Valentino Geron Date: Wed, 25 May 2022 18:25:38 +0300 Subject: 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 `/` --- tests/support/test.tcl | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'tests/support') 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 -- cgit v1.2.1