parser/gotest: Check for prefix that's not part of end-test

This commit is contained in:
Joël Stemmer 2018-04-28 18:00:34 +01:00
parent 6026e8f15e
commit 236bda9d6d
2 changed files with 15 additions and 3 deletions

View File

@ -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",

View File

@ -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",