130
// appendAlertsSuite adds a synthetic JUnit suite summarizing high-priority alerts
131
// (data races, panics, fatals) so that CI surfaces them prominently.
132
>
func (j *junitReport) appendAlertsSuite(alerts []alert) {
junit.go
133
>
// Deduplicate by type+details to avoid noisy repeats across retries.
134
>
alerts = dedupeAlerts(alerts)
135
>
if len(alerts) == 0 {
136
return
137
}
138
139
// Convert alerts to JUnit test cases.
140
>
var cases []junit.Testcase
junit.go
141
>
for _, a := range alerts {
142
>
name := fmt.Sprintf("%s: %s", a.Type, a.Summary)
143
>
if p := primaryTestName(a.Tests); p != "" {
144
>
name = fmt.Sprintf("%s — in %s", name, p)
145
>
}
146
>
var sb strings.Builder
147
>
if a.Details != "" {
148
>
sb.WriteString(truncateAlertDetails(sanitizeXML(a.Details)))
149
>
sb.WriteByte('\n')
150
>
}
151
>
if len(a.Tests) > 0 {
152
>
fmt.Fprintf(&sb, "Detected in tests:\n\t%s", strings.Join(a.Tests, "\n\t"))
153
>
}
154
>
f := generateFailure(a.Type, strings.TrimRight(sb.String(), "\n"))
155
>
cases = append(cases, junit.Testcase{
156
>
Name: name,
157
>
Failure: f,
158
>
})
159
}
160
161
// Append the alerts suite to the report.
162
>
suite := junit.Testsuite{
junit.go
163
>
Name: alertsSuiteName,
164
>
Failures: len(cases),
165
>
Tests: len(cases),
166
>
Testcases: cases,
167
>
}
168
>
j.Suites = append(j.Suites, suite)
169
>
j.Failures += suite.Failures
170
>
j.Tests += suite.Tests
171
}
172