From f11971697b3246cca8664d94cf854bf1381e92f0 Mon Sep 17 00:00:00 2001 From: Aldo Ansel Date: Fri, 1 Nov 2024 21:13:31 -0700 Subject: [PATCH 1/2] fix(validate): fixes check for test.failfast flag as this is a gotest arg and must be prefixed with test. --- cmd/main.go | 4 ++-- cmd/main_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index a71395d..48a172b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -208,8 +208,8 @@ 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("failfast", o.args) > -1 { - return fmt.Errorf("-failfast can not be used with --rerun-fails " + + if o.rerunFailsMaxAttempts > 0 && 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 diff --git a/cmd/main_test.go b/cmd/main_test.go index c28d5de..b44bdf8 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -85,8 +85,8 @@ func TestOptions_Validate_FromFlags(t *testing.T) { }, { name: "rerun-fails with failfast", - args: []string{"--rerun-fails", "--packages=./...", "--", "-failfast"}, - expected: "-failfast can not be used with --rerun-fails", + args: []string{"--rerun-fails", "--packages=./...", "--", "-test.failfast"}, + expected: "-test.failfast can not be used with --rerun-fails", }, } for _, tc := range testCases { From fd36d2ba9cbddb29e7e0a9e4d4fed74c4491f793 Mon Sep 17 00:00:00 2001 From: Aldo Ansel Date: Sun, 3 Nov 2024 15:27:54 -0800 Subject: [PATCH 2/2] fixup! fix(validate): fixes check for test.failfast flag as this is a gotest arg and must be prefixed with test. --- cmd/main.go | 6 ++++-- cmd/main_test.go | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 48a172b..2a287fc 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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 diff --git a/cmd/main_test.go b/cmd/main_test.go index b44bdf8..a619511 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -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 {