Skip to content

Commit

Permalink
dev: allow whitespace separated regexps for testlogic files
Browse files Browse the repository at this point in the history
This was a feature of `make testlogic` and it was liked.

Fixes #91125

Release note: None
  • Loading branch information
ajwerner committed Nov 2, 2022
1 parent 5640cf3 commit 47989c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=58
DEV_VERSION=59

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
18 changes: 17 additions & 1 deletion pkg/cmd/dev/testlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error {
}

if files != "" || subtests != "" {
args = append(args, "--test_filter", munge(files)+"/"+subtests)
filesRegexp := spaceSeparatedRegexpsToRegexp(files)
args = append(args, "--test_filter", filesRegexp+"/"+subtests)
args = append(args, "--test_sharding_strategy=disabled")
}
args = append(args, d.getTestOutputArgs(stress, verbose, showLogs, streamOutput)...)
Expand All @@ -259,6 +260,21 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error {
return nil
}

// We know that the regular expressions for files should not contain whitespace
// because the file names do not contain whitespace. We support users passing
// whitespace separated regexps for multiple files.
func spaceSeparatedRegexpsToRegexp(s string) string {
s = munge(s)
split := strings.Fields(s)
if len(split) < 2 {
return s
}
for i, s := range split {
split[i] = "(" + s + ")"
}
return "(" + strings.Join(split, "|") + ")"
}

func munge(s string) string {
if s == "" {
return ".*"
Expand Down

0 comments on commit 47989c6

Please sign in to comment.