mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-03 12:42:47 -05:00
parser/gotest: Handle build errors in test packages with _test suffix
It's possible for test files to declare a package with the "_test" suffix. If these packages contain build errors, they were not correctly matched to the package without the "_test" suffix. Refs #145
This commit is contained in:
@ -150,7 +150,7 @@ func (b *reportBuilder) CreatePackage(packageName, newPackageName, result string
|
||||
// First check if this package contained a build error. If that's the case,
|
||||
// we won't find any tests in this package.
|
||||
for id, buildErr := range b.buildErrors {
|
||||
if buildErr.Name == newPackageName {
|
||||
if buildErr.Name == newPackageName || strings.TrimSuffix(buildErr.Name, "_test") == newPackageName {
|
||||
pkg.BuildError = buildErr
|
||||
pkg.BuildError.ID = id
|
||||
pkg.BuildError.Duration = duration
|
||||
|
@ -392,6 +392,26 @@ func TestReportSpecialCases(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"build error in package with _test suffix",
|
||||
[]Event{
|
||||
{Type: "build_output", Name: "package/name_test"},
|
||||
{Type: "summary", Name: "package/name", Result: "FAIL", Data: "[build failed]"},
|
||||
},
|
||||
gtr.Report{
|
||||
Packages: []gtr.Package{
|
||||
{
|
||||
Name: "package/name",
|
||||
Timestamp: testTimestamp,
|
||||
BuildError: gtr.Error{
|
||||
ID: 1,
|
||||
Name: "package/name_test",
|
||||
Cause: "[build failed]",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user