Skip to content

Commit

Permalink
Test runner improvements (#6865)
Browse files Browse the repository at this point in the history
## What changed?

- Do not rerun tests if there are more than 10 failures in a single
suite. This threshold can later become configurable as needed.
- Add a sanity check to ensure test-runner reruns all failed tests as
expected.

## Why?

For confidence, this is a new tool and I don't trust it yet. The
threshold is
  • Loading branch information
bergundy authored Nov 22, 2024
1 parent 41be8ac commit b2f5cb3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/testrunner/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ func (r *runner) combineAttempts() junit.Testsuites {
continue
}

// Just a sanity check for this tool since it's new and we want to make sure we actually rerun what we
// expect.
if attempt.suites.Tests != r.attempts[i-1].suites.Failures {
log.Fatalf("expected a rerun of all failures from the previous attempt, got (%d/%d)", attempt.suites.Tests, r.attempts[i-1].suites.Failures)
}

for _, suite := range attempt.suites.Suites {
cpy := suite
cpy.Name += fmt.Sprintf(" (retry %d)", i)
Expand Down Expand Up @@ -286,6 +292,11 @@ func Main() {
if len(failures) == 0 {
log.Fatalf("tests failed but no failures have been detected, not rerunning tests")
}
// Don't rerun if there's more than 10 failures in a single suite.
if len(failures) > 10 && retry < r.retries {
log.Printf("will not rerun tests, number of failures exceeds configured threshold (%d/%d)", len(failures), 10)
break
}
args = stripRunFromArgs(args)
for i, failure := range failures {
failures[i] = goTestNameToRunFlagRegexp(failure)
Expand Down

0 comments on commit b2f5cb3

Please sign in to comment.