Skip to content

Commit

Permalink
fixup! fix(validate): fixes check for test.failfast flag as this is a…
Browse files Browse the repository at this point in the history
… gotest arg and must be prefixed with test.
  • Loading branch information
aansel-rivian committed Nov 3, 2024
1 parent f119716 commit fd36d2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ func (o options) Validate() error {
"when go test args are used with --rerun-fails " +
"the list of packages to test must be specified by the --packages flag")
}
if o.rerunFailsMaxAttempts > 0 && boolArgIndex("test.failfast", o.args) > -1 {
return fmt.Errorf("-test.failfast can not be used with --rerun-fails " +
if o.rerunFailsMaxAttempts > 0 &&
(boolArgIndex("failfast", o.args) > -1 ||
boolArgIndex("test.failfast", o.args) > -1) {
return fmt.Errorf("-(test.)failfast can not be used with --rerun-fails " +
"because not all test cases will run")
}
return nil
Expand Down
7 changes: 6 additions & 1 deletion cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ func TestOptions_Validate_FromFlags(t *testing.T) {
name: "rerun flag, no go-test args, with packages flag",
args: []string{"--rerun-fails", "--packages", "./..."},
},
{
name: "rerun-fails with failfast",
args: []string{"--rerun-fails", "--packages=./...", "--", "-failfast"},
expected: "-(test.)failfast can not be used with --rerun-fails",
},
{
name: "rerun-fails with failfast",
args: []string{"--rerun-fails", "--packages=./...", "--", "-test.failfast"},
expected: "-test.failfast can not be used with --rerun-fails",
expected: "-(test.)failfast can not be used with --rerun-fails",
},
}
for _, tc := range testCases {
Expand Down

0 comments on commit fd36d2b

Please sign in to comment.