mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-04-11 08:08:07 -05:00
parser/gotest: Check for prefix that's not part of end-test
This commit is contained in:
parent
6026e8f15e
commit
236bda9d6d
@ -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",
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user