Fix regular expression for summary with "no statements" coverage.

Move the status message to the end of the regular expression.
This commit is contained in:
kevinwang
2022-08-29 18:58:51 +00:00
parent 7b10b42854
commit 9c64855bf7
2 changed files with 23 additions and 6 deletions

View File

@ -37,11 +37,12 @@ var (
`(?:\s+(\d+\.\d+)s)?` +
// 4: cached indicator (optional)
`(?:\s+(\(cached\)))?` +
// 5: [status message] (optional)
// 5: coverage percentage (optional)
// 6: coverage package list (optional)
`(?:\s+coverage:\s+(?:\[no\sstatements\]|(\d+\.\d+)%\sof\sstatements(?:\sin\s(.+))?))?` +
// 7: [status message] (optional)
`(?:\s+(\[[^\]]+\]))?` +
// 6: coverage percentage (optional)
// 7: coverage package list (optional)
`(?:\s+coverage:\s+(\d+\.\d+)%\sof\sstatements(?:\sin\s(.+))?)?$`)
`$`)
)
// Option defines options that can be passed to gotest.New.
@ -200,7 +201,7 @@ func (p *Parser) parseLine(line string) (events []Event) {
} else if matches := regexStatus.FindStringSubmatch(line); len(matches) == 2 {
return p.status(matches[1])
} else if matches := regexSummary.FindStringSubmatch(line); len(matches) == 8 {
return p.summary(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6], matches[7])
return p.summary(matches[1], matches[2], matches[3], matches[4], matches[7], matches[5], matches[6])
} else if matches := regexCoverage.FindStringSubmatch(line); len(matches) == 3 {
return p.coverage(matches[1], matches[2])
} else if matches := regexBenchmark.FindStringSubmatch(line); len(matches) == 2 {