Skip to content

Commit

Permalink
support regex in "--only" in runtest (#9352)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoav-steinberg committed Aug 10, 2021
1 parent 8ab33c1 commit 19bc837
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion tests/support/test.tcl
Expand Up @@ -115,6 +115,17 @@ proc wait_for_condition {maxtries delay e _else_ elsescript} {
}
}

proc search_pattern_list {value pattern_list} {
set n 0
foreach el $pattern_list {
if {[regexp -- $el $value]} {
return $n
}
incr n
}
return -1
}

proc test {name code {okpattern undefined} {tags {}}} {
# abort if test name in skiptests
if {[lsearch $::skiptests $name] >= 0} {
Expand All @@ -124,7 +135,7 @@ proc test {name code {okpattern undefined} {tags {}}} {
}

# abort if only_tests was set but test name is not included
if {[llength $::only_tests] > 0 && [lsearch $::only_tests $name] < 0} {
if {[llength $::only_tests] > 0 && [search_pattern_list $name $::only_tests] < 0} {
incr ::num_skipped
send_data_packet $::test_server_fd skip $name
return
Expand Down
2 changes: 1 addition & 1 deletion tests/test_helper.tcl
Expand Up @@ -562,7 +562,7 @@ 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 the specified test by test name. This option can be repeated."
"--only <test> Just execute tests that match <test> regexp. 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)."
Expand Down

0 comments on commit 19bc837

Please sign in to comment.