Add state to ignore trailing output

This commit is contained in:
Ingmar Stein
2017-07-26 08:06:07 +02:00
parent 0f1caf6c3e
commit 862454a821
3 changed files with 18 additions and 21 deletions

View File

@ -64,6 +64,9 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
// current test
var cur string
// keep track if we've already seen a summary for the current test
var seenSummary bool
// coverage percentage report for current package
var coveragePct string
@ -98,6 +101,7 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
// clear the current build package, so output lines won't be added to that build
capturedPackage = ""
seenSummary = false
} else if matches := regexResult.FindStringSubmatch(line); len(matches) == 6 {
if matches[5] != "" {
coveragePct = matches[5]
@ -172,15 +176,17 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
// current line is build failure capture for the current built package
packageCaptures[capturedPackage] = append(packageCaptures[capturedPackage], line)
} else if regexSummary.MatchString(line) {
// ignore
// don't store any output after the summary
seenSummary = true
} else {
test := findTest(tests, cur)
if test == nil {
// buffer anything else that we didn't recognize
buffer = append(buffer, line)
} else {
test.Output = append(test.Output, line)
if !seenSummary {
if test := findTest(tests, cur); test != nil {
test.Output = append(test.Output, line)
continue
}
}
// buffer anything else that we didn't recognize
buffer = append(buffer, line)
}
}