parser/gotest: Parse cached tests

This commit is contained in:
Joël Stemmer 2018-04-28 18:21:42 +01:00
parent 76069cb328
commit a7ad52d825
2 changed files with 9 additions and 4 deletions

View File

@ -28,7 +28,7 @@ var (
regexEndTest = regexp.MustCompile(`((?: )*)--- (PASS|FAIL|SKIP): ([^ ]+) \((\d+\.\d+)(?: seconds|s)\)`) regexEndTest = regexp.MustCompile(`((?: )*)--- (PASS|FAIL|SKIP): ([^ ]+) \((\d+\.\d+)(?: seconds|s)\)`)
regexStatus = regexp.MustCompile(`^(PASS|FAIL|SKIP)$`) regexStatus = regexp.MustCompile(`^(PASS|FAIL|SKIP)$`)
regexSummary = regexp.MustCompile(`^(ok|FAIL)\s+([^ ]+)\s+` + regexSummary = regexp.MustCompile(`^(ok|FAIL)\s+([^ ]+)\s+` +
`(?:(\d+\.\d+)s|\(cached\)|(\[\w+ failed]))` + `(?:(\d+\.\d+)s|(\(cached\)|\[\w+ failed]))` +
`(?:\s+coverage:\s+(\d+\.\d+)%\sof\sstatements(?:\sin\s(.+))?)?$`) `(?:\s+coverage:\s+(\d+\.\d+)%\sof\sstatements(?:\sin\s(.+))?)?$`)
regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+|\d+\.\d+)%\s+of\s+statements(?:\sin\s(.+))?$`) regexCoverage = regexp.MustCompile(`^coverage:\s+(\d+|\d+\.\d+)%\s+of\s+statements(?:\sin\s(.+))?$`)
) )
@ -135,13 +135,13 @@ func (p *parser) status(result string) {
}) })
} }
func (p *parser) summary(result, name, duration, failure, covpct, packages string) { func (p *parser) summary(result, name, duration, data, covpct, packages string) {
p.add(Event{ p.add(Event{
Type: "summary", Type: "summary",
Result: result, Result: result,
Name: name, Name: name,
Duration: parseSeconds(duration), Duration: parseSeconds(duration),
Data: failure, Data: data,
CovPct: parseCoverage(covpct), CovPct: parseCoverage(covpct),
CovPackages: parsePackages(packages), CovPackages: parsePackages(packages),
}) })

View File

@ -320,7 +320,12 @@ var tests = []struct {
{Type: "summary", Result: "FAIL", Name: "pkg/parallel", Duration: 3010 * time.Millisecond}, {Type: "summary", Result: "FAIL", Name: "pkg/parallel", Duration: 3010 * time.Millisecond},
}}, }},
{"21-cached", {"21-cached",
[]Event{}}, []Event{
{Type: "run_test", Id: 1, Name: "TestOne"},
{Type: "end_test", Id: 1, Name: "TestOne", Result: "PASS"},
{Type: "status", Result: "PASS"},
{Type: "summary", Result: "ok", Name: "package/one", Data: "(cached)"},
}},
{"22-whitespace", {"22-whitespace",
[]Event{}}, []Event{}},
} }