215
}
216
217
>
func (j *junitReport) collectTestCases() map[string]struct{} {
junit.go
218
>
cases := make(map[string]struct{})
219
>
for _, suite := range j.Suites {
220
>
for _, tc := range suite.Testcases {
221
>
cases[tc.Name] = struct{}{}
222
>
}
223
}
225
}
226
227
>
func (j *junitReport) collectTestCaseFailures() []string {
junit.go
228
>
var failures []string
229
>
for _, suite := range j.Suites {
230
>
if suite.Failures == 0 {
231
continue
232
}
233
>
for _, tc := range suite.Testcases {
junit.go
234
>
if tc.Failure != nil {
235
>
failures = append(failures, tc.Name)
236
>
}
237
}
238
}
239
240
// Sort lexicographically
242
>
243
>
// Find leaf failures using the simplified algorithm
244
>
var leafFailures []string
245
>
for i := 0; i < len(failures)-1; i++ {
246
>
if !strings.HasPrefix(failures[i+1], failures[i]+"/") {
junit.go
247
leafFailures = append(leafFailures, failures[i])
248
}
249
}
251
>
leafFailures = append(leafFailures, failures[len(failures)-1])
252
>
}
253
255
}
256
257
>
func mergeReports(reports []*junitReport) (*junitReport, error) {
junit.go
258
>
if len(reports) == 0 {
259
return nil, errors.New("no reports to merge")
260
}
261
262
>
var reportingErrs []error
junit.go
263
>
var combined junit.Testsuites
264
>
combined.XMLName = reports[0].XMLName
265
>
combined.Name = reports[0].Name
266
>
267
>
for i, report := range reports {
268
>
combined.Tests += report.Tests
269
>
combined.Errors += report.Errors
270
>
combined.Failures += report.Failures
271
>
combined.Skipped += report.Skipped
272
>
combined.Disabled += report.Disabled
273
>
combined.Time += report.Time
274
>
275
>
// If the report is for a retry ...
276
>
var suffix string
277
>
if i > 0 {
278
>
suffix = fmt.Sprintf(" (retry %d)", i)
junit.go
279
>
if i == len(reports)-1 {
280
>
suffix += " (final)"
281
>
}
282
>
prevFailures := reports[i-1].collectTestCaseFailures()
283
>
currCases := report.collectTestCases()
284
>
285
>
var missing []string
286
>
for _, f := range prevFailures {
287
>
if _, ok := currCases[f]; !ok {
288
missing = append(missing, f)
289
}
290
}
292
reportingErrs = append(reportingErrs, fmt.Errorf(
293
"expected rerun of all failures from previous attempt, missing: %v", missing))