Skip to content

Commit

Permalink
Cancel re-run if there are any errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 12, 2020
1 parent 3381e15 commit ccefcdd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rerunfails.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/pkg/errors"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/testjson"
)

Expand Down Expand Up @@ -34,11 +35,13 @@ func rerunFailed(ctx context.Context, opts *options, scanConfig testjson.ScanCon
}

rec := newFailureRecorderFromExecution(scanConfig.Execution)

var lastErr error
for count := 0; rec.count() > 0 && count < opts.rerunFailsMaxAttempts; count++ {
nextRec := newFailureRecorder(scanConfig.Handler)
if len(scanConfig.Execution.Errors()) > 0 {
return fmt.Errorf("re-run cancelled because previous run had errors")
}

nextRec := newFailureRecorder(scanConfig.Handler)
for pkg, testCases := range rec.pkgFailures {
rerun := rerunOpts{
runFlag: goTestRunFlagFromTestCases(testCases),
Expand All @@ -59,6 +62,8 @@ func rerunFailed(ctx context.Context, opts *options, scanConfig testjson.ScanCon
return err
}
lastErr = goTestProc.cmd.Wait()
log.Warnf("go test exit code: %v", lastErr)
// TODO: will 'go test' exit with 2 if it panics? possibly error on that
rec = nextRec
}
}
Expand Down

0 comments on commit ccefcdd

Please sign in to comment.