diff --git a/pkg/parser/gotest/gotest.go b/pkg/parser/gotest/gotest.go index 1c730c2..188b536 100644 --- a/pkg/parser/gotest/gotest.go +++ b/pkg/parser/gotest/gotest.go @@ -3,6 +3,7 @@ package gotest import ( "bufio" + "fmt" "io" "regexp" "strconv" @@ -58,7 +59,7 @@ func (p *parser) parseLine(line string) { } else if strings.HasPrefix(line, "=== PAUSE ") { } else if strings.HasPrefix(line, "=== CONT ") { } else if matches := regexEndTest.FindStringSubmatch(line); len(matches) == 5 { - p.endTest(matches[1], matches[2], matches[3], matches[4]) + p.endTest(line, matches[1], matches[2], matches[3], matches[4]) } else if matches := regexStatus.FindStringSubmatch(line); len(matches) == 2 { p.status(matches[1]) } else if matches := regexSummary.FindStringSubmatch(line); len(matches) == 7 { @@ -93,7 +94,10 @@ func (p *parser) runTest(name string) { }) } -func (p *parser) endTest(indent, result, name, duration string) { +func (p *parser) endTest(line, indent, result, name, duration string) { + if idx := strings.Index(line, fmt.Sprintf("%s--- %s:", indent, result)); idx > 0 { + p.output(line[:idx]) + } _, n := stripIndent(indent) p.add(Event{ Type: "end_test", diff --git a/pkg/parser/gotest/gotest_test.go b/pkg/parser/gotest/gotest_test.go index e051e06..2590e8f 100644 --- a/pkg/parser/gotest/gotest_test.go +++ b/pkg/parser/gotest/gotest_test.go @@ -288,7 +288,15 @@ var tests = []struct { {Type: "summary", Result: "ok", Name: "package2/bar", Duration: 4200 * time.Millisecond, CovPct: 99.8, CovPackages: []string{"fmt", "encoding/xml"}}, }}, {"19-pass", - []Event{}}, + []Event{ + {Type: "run_test", Id: 1, Name: "TestZ"}, + {Type: "output", Data: "some inline text"}, + {Type: "end_test", Id: 1, Name: "TestZ", Result: "PASS", Duration: 60 * time.Millisecond}, + {Type: "run_test", Id: 2, Name: "TestA"}, + {Type: "end_test", Id: 2, Name: "TestA", Result: "PASS", Duration: 100 * time.Millisecond}, + {Type: "status", Result: "PASS"}, + {Type: "summary", Result: "ok", Name: "package/name", Duration: 160 * time.Millisecond}, + }}, {"20-parallel", []Event{}}, {"21-cached",