Skip to content

Commit

Permalink
Include run count in DONe line
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 20, 2020
1 parent 83c209d commit a78bf96
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SEED: 1
FAIL testdata/e2e/flaky.TestFailsOften (re-run 1)
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures
DONE 2 runs, 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes (re-run 2)
=== RUN TestFailsOften
Expand Down Expand Up @@ -69,4 +69,4 @@ SEED: 2
flaky_test.go:65: not this time


DONE 11 tests, 6 failures
DONE 3 runs, 11 tests, 6 failures
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SEED: 1
FAIL testdata/e2e/flaky.TestFailsOften (re-run 1)
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures
DONE 2 runs, 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes (re-run 2)
=== RUN TestFailsOften
Expand Down Expand Up @@ -69,4 +69,4 @@ SEED: 2
TestFailsOften: flaky_test.go:65: not this time


DONE 11 tests, 6 failures
DONE 3 runs, 11 tests, 6 failures
8 changes: 4 additions & 4 deletions testdata/e2e/expected/TestE2E_RerunFails/reruns_until_success
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SEED: 1
FAIL testdata/e2e/flaky.TestFailsOften (re-run 1)
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures
DONE 2 runs, 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes (re-run 2)
=== RUN TestFailsOften
Expand All @@ -43,7 +43,7 @@ SEED: 2
FAIL testdata/e2e/flaky.TestFailsOften (re-run 2)
FAIL testdata/e2e/flaky

DONE 11 tests, 6 failures
DONE 3 runs, 11 tests, 6 failures

=== RUN TestFailsOften
SEED: 3
Expand All @@ -52,7 +52,7 @@ SEED: 3
FAIL testdata/e2e/flaky.TestFailsOften (re-run 3)
FAIL testdata/e2e/flaky

DONE 12 tests, 7 failures
DONE 4 runs, 12 tests, 7 failures

PASS testdata/e2e/flaky.TestFailsOften (re-run 4)
PASS testdata/e2e/flaky
Expand Down Expand Up @@ -87,4 +87,4 @@ SEED: 3
flaky_test.go:65: not this time


DONE 13 tests, 7 failures
DONE 5 runs, 13 tests, 7 failures
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SEED: 1
FAIL testdata/e2e/flaky.TestFailsOften (re-run 1)
FAIL testdata/e2e/flaky

DONE 9 tests, 5 failures
DONE 2 runs, 9 tests, 5 failures

PASS testdata/e2e/flaky.TestFailsSometimes (re-run 2)
=== RUN TestFailsOften
Expand All @@ -43,7 +43,7 @@ SEED: 2
FAIL testdata/e2e/flaky.TestFailsOften (re-run 2)
FAIL testdata/e2e/flaky

DONE 11 tests, 6 failures
DONE 3 runs, 11 tests, 6 failures

=== RUN TestFailsOften
SEED: 3
Expand All @@ -52,7 +52,7 @@ SEED: 3
FAIL testdata/e2e/flaky.TestFailsOften (re-run 3)
FAIL testdata/e2e/flaky

DONE 12 tests, 7 failures
DONE 4 runs, 12 tests, 7 failures

PASS testdata/e2e/flaky.TestFailsOften (re-run 4)
PASS testdata/e2e/flaky
Expand Down Expand Up @@ -87,4 +87,4 @@ SEED: 3
TestFailsOften: flaky_test.go:65: not this time


DONE 13 tests, 7 failures
DONE 5 runs, 13 tests, 7 failures
12 changes: 8 additions & 4 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ func newPackage() *Package {

// Execution of one or more test packages
type Execution struct {
started time.Time
packages map[string]*Package
errors []string
done bool
started time.Time
packages map[string]*Package
errors []string
done bool
lastRunID int
}

func (e *Execution) add(event TestEvent) {
Expand Down Expand Up @@ -508,6 +509,9 @@ func ScanTestOutput(config ScanConfig) (*Execution, error) {
if execution == nil {
execution = newExecution()
}
execution.done = false
execution.lastRunID = config.RunID

var group errgroup.Group
group.Go(func() error {
return readStdout(config, execution)
Expand Down
15 changes: 9 additions & 6 deletions testjson/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PrintSummary(out io.Writer, execution *Execution, opts Summary) {
}

fmt.Fprintf(out, "\n%s %d tests%s%s%s in %s\n",
formatExecStatus(execution.done),
formatExecStatus(execution),
execution.Total(),
formatTestCount(len(execution.Skipped()), "skipped", ""),
formatTestCount(len(execution.Failed()), "failure", "s"),
Expand All @@ -101,12 +101,15 @@ func formatTestCount(count int, category string, pluralize string) string {
return fmt.Sprintf(", %d %s", count, category)
}

// TODO: maybe color this?
func formatExecStatus(done bool) string {
if done {
return "DONE"
func formatExecStatus(exec *Execution) string {
if !exec.done {
return ""
}
var runs string
if exec.lastRunID > 0 {
runs = fmt.Sprintf(" %d runs,", exec.lastRunID+1)
}
return ""
return "DONE" + runs
}

// FormatDurationAsSeconds formats a time.Duration as a float with an s suffix.
Expand Down
2 changes: 1 addition & 1 deletion testjson/testdata/summary-with-run-id.out
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ this is stderr
=== FAIL: github.com/gotestyourself/gotestyourself/testjson/internal/stub TestNestedWithFailure (re-run 7) (0.00s)


DONE 46 tests, 4 skipped, 5 failures in 0.000s
DONE 8 runs, 46 tests, 4 skipped, 5 failures in 0.000s

0 comments on commit a78bf96

Please sign in to comment.