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 `/`
This commit is contained in:
Valentino Geron 2022-05-25 18:25:38 +03:00 committed by GitHub
parent 450c88f368
commit 9eb97b5d94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View File

@ -441,7 +441,7 @@ proc run_tests {} {
file delete $::leaked_fds_file
}
if {[llength $::run_matching] != 0 && [search_pattern_list $test $::run_matching true] == -1} {
if {[llength $::run_matching] != 0 && ![search_pattern_list $test $::run_matching true]} {
continue
}
if {[file isdirectory $test]} continue
@ -699,4 +699,4 @@ proc redis_client {type id} {
proc redis_client_by_addr {host port} {
set client [redis $host $port 0 $::tls]
return $client
}
}

View File

@ -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

View File

@ -588,15 +588,15 @@ proc print_help_screen {} {
"--single <unit> Just execute the specified unit (see next option). This option can be repeated."
"--verbose Increases verbosity."
"--list-tests List all the available test units."
"--only <test> Just execute tests that match <test> regexp. This option can be repeated."
"--only <test> Just execute the specified test by test name or tests that match <test> regexp (if <test> starts with '/'). This option can be repeated."
"--skip-till <unit> Skip all units until (and including) the specified one."
"--skipunit <unit> Skip one unit."
"--clients <num> Number of test clients (default 16)."
"--timeout <sec> Test timeout in seconds (default 20 min)."
"--force-failure Force the execution of a test that always fails."
"--config <k> <v> Extra config file argument."
"--skipfile <file> Name of a file containing test names or regexp patterns that should be skipped (one per line)."
"--skiptest <test> Test name or regexp pattern to skip. This option can be repeated."
"--skipfile <file> Name of a file containing test names or regexp patterns (if <test> starts with '/') that should be skipped (one per line)."
"--skiptest <test> Test name or regexp pattern (if <test> starts with '/') to skip. This option can be repeated."
"--tags <tags> Run only tests having specified tags or not having '-' prefixed tags."
"--dont-clean Don't delete redis log files after the run."
"--no-latency Skip latency measurements and validation by some tests."