Skip to content

Commit

Permalink
Merge pull request #280 from gotestyourself/error-when-failfast-with-…
Browse files Browse the repository at this point in the history
…rerun

Error if `-failfast` is used with `--rerun-fails`
  • Loading branch information
dnephin committed Oct 2, 2022
2 parents 338c8c8 + f59fd5d commit f233ea0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,13 @@ type options struct {
func (o options) Validate() error {
if o.rerunFailsMaxAttempts > 0 && len(o.args) > 0 && !o.rawCommand && len(o.packages) == 0 {
return fmt.Errorf(
"when go test args are used with --rerun-fails-max-attempts " +
"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("failfast", o.args) > -1 {
return fmt.Errorf("-failfast can not be used with --rerun-fails " +
"because not all test cases will run")
}
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ 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: "-failfast can not be used with --rerun-fails",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit f233ea0

Please sign in to comment.