Skip to content

Commit

Permalink
Merge pull request #106 from dnephin/tests-can-have-more-than-2-frami…
Browse files Browse the repository at this point in the history
…ng-events

Tests can have more than 2 framing lines
  • Loading branch information
dnephin committed Apr 25, 2020
2 parents 32e482f + 8ee9a8b commit 6878800
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,13 @@ func (p Package) Output(test string) string {
// OutputLines returns the full test output for a test as a slice of strings.
//
// As a workaround for test output being attributed to the wrong subtest, if:
// - the requested test output only contains framing lines (ex: --- FAIL: ), and
// - the TestCase is a root TestCase (not a subtest), and
// - the TestCase has no subtest failures;
// then all output for every subtest under the root test is returned.
// See https://github.com/golang/go/issues/29755.
func (p Package) OutputLines(tc TestCase) []string {
root, sub := splitTestName(tc.Test)
lines := p.output[root][sub]
// every test will have 2 framing lines, === RUN, and --- {PASS,FAIL}
if len(lines) > 2 {
return lines
}

// If this is a subtest, or a root test case with subtest failures the
// subtest failure output should contain the relevant lines, so we don't need
Expand Down
2 changes: 1 addition & 1 deletion testjson/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func formatExecStatus(done bool) string {
// FormatDurationAsSeconds formats a time.Duration as a float with an s suffix.
func FormatDurationAsSeconds(d time.Duration, precision int) string {
if d == neverFinished {
return "panic"
return "unknown"
}
return fmt.Sprintf("%.[2]*[1]fs", d.Seconds(), precision)
}
Expand Down
2 changes: 1 addition & 1 deletion testjson/testdata/summary-missing-test-fail-event
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

=== Failed
=== FAIL: gotest.tools/v3/poll TestWaitOn_WithCompare (panic)
=== FAIL: gotest.tools/v3/poll TestWaitOn_WithCompare (unknown)
panic: runtime error: index out of range [1] with length 1

goroutine 7 [running]:
Expand Down

0 comments on commit 6878800

Please sign in to comment.