Include failing packages without tests in report

If a package compiles correctly, but panics before it has a chance to
run any tests it would previously be ignored. Any failing packages
without tests but with some output will now be included in the report
with a dummy test.

Fixes #52
This commit is contained in:
Joël Stemmer
2017-04-27 23:19:32 +01:00
parent dd4990585e
commit 2a5fd0eeb0
6 changed files with 101 additions and 0 deletions

View File

@ -72,6 +72,9 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
// the name of the package which it's build failure output is being captured
var capturedPackage string
// capture any non-test output
var buffer []string
// parse lines
for {
l, _, err := reader.ReadLine()
@ -106,6 +109,15 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
Result: FAIL,
Output: packageCaptures[matches[2]],
})
} else if matches[1] == "FAIL" && len(tests) == 0 && len(buffer) > 0 {
// This package didn't have any tests, but it failed with some
// output. Create a dummy test with the output.
tests = append(tests, &Test{
Name: "Failure",
Result: FAIL,
Output: buffer,
})
buffer = buffer[0:0]
}
// all tests in this package are finished
@ -116,6 +128,7 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
CoveragePct: coveragePct,
})
buffer = buffer[0:0]
tests = make([]*Test, 0)
coveragePct = ""
cur = ""
@ -157,6 +170,9 @@ func Parse(r io.Reader, pkgName string) (*Report, error) {
} else if capturedPackage != "" {
// current line is build failure capture for the current built package
packageCaptures[capturedPackage] = append(packageCaptures[capturedPackage], line)
} else {
// buffer anything else that we didn't recognize
buffer = append(buffer, line)
}
}