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 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 Just execute tests that match regexp. This option can be repeated." + "--only Just execute the specified test by test name or tests that match regexp (if starts with '/'). This option can be repeated." "--skip-till Skip all units until (and including) the specified one." "--skipunit Skip one unit." "--clients Number of test clients (default 16)." "--timeout Test timeout in seconds (default 20 min)." "--force-failure Force the execution of a test that always fails." "--config Extra config file argument." - "--skipfile Name of a file containing test names or regexp patterns that should be skipped (one per line)." - "--skiptest Test name or regexp pattern to skip. This option can be repeated." + "--skipfile Name of a file containing test names or regexp patterns (if starts with '/') that should be skipped (one per line)." + "--skiptest Test name or regexp pattern (if starts with '/') to skip. This option can be repeated." "--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."