Skip to content

Commit

Permalink
rerun: add done line, and only warn on exit !{0,1}
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 12, 2020
1 parent e8026de commit bb6a8a5
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
5 changes: 5 additions & 0 deletions do
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ binary() {
}

update-golden() {
_update-golden
GOLANG_VERSION=1.13-alpine ./do shell bash -c 'go build; PATH=$PATH:. ./do _update-golden'
}

_update-golden() {
gotestsum -- . ./testjson ./internal/junitxml ./cmd/tool/slowest -test.update-golden
}

Expand Down
10 changes: 8 additions & 2 deletions rerunfails.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func rerunFailed(ctx context.Context, opts *options, scanConfig testjson.ScanCon
return fmt.Errorf("re-run cancelled because previous run had errors")
}

testjson.PrintSummary(opts.stdout, scanConfig.Execution, testjson.SummarizeNone)
opts.stdout.Write([]byte("\n")) // nolint: errcheck

nextRec := newFailureRecorder(scanConfig.Handler)
for pkg, testCases := range rec.pkgFailures {
rerun := rerunOpts{
Expand All @@ -62,8 +65,11 @@ 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
// 0 and 1 are expected.
if ExitCodeWithDefault(lastErr) > 1 {
log.Warnf("unexpected go test exit code: %v", lastErr)
// TODO: will 'go test' exit with 2 if it panics? maybe return err here.
}
rec = nextRec
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky

DONE 6 tests, 3 failures

PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
SEED: 1
Expand All @@ -29,6 +32,9 @@ SEED: 1
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes
=== RUN TestFailsOften
SEED: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky

DONE 6 tests, 3 failures

PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
SEED: 1
Expand All @@ -29,6 +32,9 @@ SEED: 1
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes
=== RUN TestFailsOften
SEED: 2
Expand Down
12 changes: 12 additions & 0 deletions testdata/e2e/expected/TestE2E_RerunFails/reruns_until_success
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky

DONE 6 tests, 3 failures

PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
SEED: 1
Expand All @@ -29,19 +32,28 @@ SEED: 1
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes
=== RUN TestFailsOften
SEED: 2
--- FAIL: TestFailsOften
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 11 tests, 6 failures

=== RUN TestFailsOften
SEED: 3
--- FAIL: TestFailsOften
flaky_test.go:65: not this time
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 12 tests, 7 failures

PASS testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FAIL testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky.TestFailsOftenDoesNotPrefixMatch
PASS testdata/e2e/flaky.TestFailsSometimesDoesNotPrefixMatch
FAIL testdata/e2e/flaky

DONE 6 tests, 3 failures

PASS testdata/e2e/flaky.TestFailsRarely
=== RUN TestFailsSometimes
SEED: 1
Expand All @@ -29,19 +32,28 @@ SEED: 1
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes
=== RUN TestFailsOften
SEED: 2
TestFailsOften: flaky_test.go:65: not this time
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 11 tests, 6 failures

=== RUN TestFailsOften
SEED: 3
TestFailsOften: flaky_test.go:65: not this time
--- FAIL: TestFailsOften
FAIL testdata/e2e/flaky.TestFailsOften
FAIL testdata/e2e/flaky

DONE 12 tests, 7 failures

PASS testdata/e2e/flaky.TestFailsOften
PASS testdata/e2e/flaky

Expand Down

0 comments on commit bb6a8a5

Please sign in to comment.