Skip to content

Commit

Permalink
Update flag parsing for tests to work with GoLand
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Oct 4, 2022
1 parent d49c352 commit e012fae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion go/internal/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,20 @@ func Usage() {
// filterTestFlags returns two slices: the second one has just the flags for `go test` and the first one contains
// the rest of the flags.
const goTestFlagSuffix = "-test"
const goTestRunFlag = "-test.run"

func filterTestFlags() ([]string, []string) {
args := os.Args
var testFlags []string
var otherArgs []string
isRunFlag := false
for i := 0; 0 < len(args) && i < len(args); i++ {
if strings.HasPrefix(args[i], goTestFlagSuffix) {
if strings.HasPrefix(args[i], goTestFlagSuffix) || isRunFlag {
isRunFlag = false
testFlags = append(testFlags, args[i])
if args[i] == goTestRunFlag {
isRunFlag = true
}
continue
}
otherArgs = append(otherArgs, args[i])
Expand Down

0 comments on commit e012fae

Please sign in to comment.