Skip to content

Commit

Permalink
Expose a flag for reruning the entire root test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Aug 28, 2022
1 parent 7b7f7dc commit 2fcecfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 3 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
"space separated list of package to test")
flags.StringVar(&opts.rerunFailsReportFile, "rerun-fails-report", "",
"write a report to the file, of the tests that were rerun")
flags.BoolVar(&opts.rerunFailsOnlyRootCases, "rerun-fails-only-root-testcases", false,
"rerun only root testcaes, instead of only subtests")
flags.Lookup("rerun-fails-only-root-testcases").Hidden = true
flags.BoolVar(&opts.rerunFailsRunRootCases, "rerun-fails-run-root-test", false,
"rerun the entire root testcase when any of its subtests fail, instead of only the failed subtest")

flags.BoolVar(&opts.debug, "debug", false, "enabled debug logging")
flags.BoolVar(&opts.version, "version", false, "show version and exit")
Expand Down Expand Up @@ -159,7 +158,7 @@ type options struct {
rerunFailsMaxAttempts int
rerunFailsMaxInitialFailures int
rerunFailsReportFile string
rerunFailsOnlyRootCases bool
rerunFailsRunRootCases bool
packages []string
watch bool
maxFails int
Expand Down
10 changes: 8 additions & 2 deletions cmd/rerunfails.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ func newRerunOptsFromTestCase(tc testjson.TestCase) rerunOpts {
type testCaseFilter func([]testjson.TestCase) []testjson.TestCase

func rerunFailsFilter(o *options) testCaseFilter {
if o.rerunFailsOnlyRootCases {
if o.rerunFailsRunRootCases {
return func(tcs []testjson.TestCase) []testjson.TestCase {
return tcs
var result []testjson.TestCase
for _, tc := range tcs {
if !tc.Test.IsSubTest() {
result = append(result, tc)
}
}
return result
}
}
return testjson.FilterFailedUnique
Expand Down

0 comments on commit 2fcecfb

Please sign in to comment.