diff options
author | Valentino Geron <valentino@redislabs.com> | 2022-05-25 18:25:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 18:25:38 +0300 |
commit | 9eb97b5d94ca4434f9035af164fe3a48dca31de2 (patch) | |
tree | 9ad7ef3f4ec0462d35df0cb060f3f0e2b83a1478 | |
parent | 450c88f368317ae9d2d3d597cf121999660e2934 (diff) | |
download | redis-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 `/`
-rw-r--r-- | tests/instances.tcl | 4 | ||||
-rw-r--r-- | tests/support/test.tcl | 26 | ||||
-rw-r--r-- | tests/test_helper.tcl | 6 |
3 files changed, 22 insertions, 14 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl index e1516c1ac..a92c5e553 100644 --- a/tests/instances.tcl +++ b/tests/instances.tcl @@ -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 -}
\ No newline at end of file +} 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 diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 134c5c46b..2dcccb8cf 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -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." |