Skip to content

Commit 20407f2

Browse files
committed
More spacing
1 parent 52e254a commit 20407f2

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

tools/flakeguard/reports/reports.go

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ func AggregateTestResults(folderPath string) (*TestReport, error) {
178178
}
179179

180180
// PrintTests prints tests in a pretty format
181-
func PrintTests(w io.Writer, tests []TestResult, maxPassRatio float64) (allRuns, passes, fails, skips, races, panics, flakes int) {
181+
func PrintTests(w io.Writer, tests []TestResult, maxPassRatio float64) (allRuns, passes, fails, panics, skips, races, flakes int) {
182182
headers := []string{
183183
"Test Name", "Test Package", "Pass Ratio", "Skipped", "Runs", "Successes", "Failures", "Panics", "Races", "Skips", "Avg Duration",
184184
}
185-
rows := [][]string{}
186185

186+
// Build test rows and summary data
187+
rows := [][]string{}
187188
for _, test := range tests {
188189
if test.PassRatio < maxPassRatio {
189190
rows = append(rows, []string{
@@ -210,8 +211,44 @@ func PrintTests(w io.Writer, tests []TestResult, maxPassRatio float64) (allRuns,
210211
flakes += fails + races + panics
211212
}
212213

213-
// Determine column widths for clean printing
214-
colWidths := make([]int, len(headers))
214+
// Print out summary data
215+
summaryData := [][]string{
216+
{"**Summary**", "**Value**"},
217+
{"Runs", fmt.Sprint(allRuns)},
218+
{"Passes", fmt.Sprint(passes)},
219+
{"Failures", fmt.Sprint(fails)},
220+
{"Panics", fmt.Sprint(panics)},
221+
{"Skips", fmt.Sprint(skips)},
222+
{"Races", fmt.Sprint(races)},
223+
{"Flakes", fmt.Sprint(flakes)},
224+
}
225+
colWidths := make([]int, len(rows[0]))
226+
227+
for _, row := range summaryData {
228+
for i, cell := range row {
229+
if len(cell) > colWidths[i] {
230+
colWidths[i] = len(cell)
231+
}
232+
}
233+
}
234+
235+
printRow := func(cells []string) {
236+
fmt.Fprintf(w, "| %-*s | %-*s |\n", colWidths[0], cells[0], colWidths[1], cells[1])
237+
}
238+
printSeparator := func() {
239+
fmt.Fprintf(w, "|-%s-|-%s-|\n", strings.Repeat("-", colWidths[0]), strings.Repeat("-", colWidths[1]))
240+
}
241+
printSeparator()
242+
printRow(summaryData[0])
243+
printSeparator()
244+
for _, row := range summaryData[1:] {
245+
printRow(row)
246+
}
247+
printSeparator()
248+
fmt.Fprintln(w)
249+
250+
// Print out test data
251+
colWidths = make([]int, len(headers))
215252
for i, header := range headers {
216253
colWidths[i] = len(header)
217254
}
@@ -223,15 +260,15 @@ func PrintTests(w io.Writer, tests []TestResult, maxPassRatio float64) (allRuns,
223260
}
224261
}
225262

226-
printRow := func(cells []string) {
263+
printRow = func(cells []string) {
227264
var buffer bytes.Buffer
228265
for i, cell := range cells {
229266
buffer.WriteString(fmt.Sprintf(" %-*s |", colWidths[i], cell))
230267
}
231268
fmt.Fprintln(w, "|"+buffer.String())
232269
}
233270

234-
printSeparator := func() {
271+
printSeparator = func() {
235272
var buffer bytes.Buffer
236273
for _, width := range colWidths {
237274
buffer.WriteString(" " + strings.Repeat("-", width) + " |")
@@ -289,6 +326,7 @@ func MarkdownSummary(w io.Writer, testReport *TestReport, maxPassRatio float64)
289326
}
290327
fmt.Fprint(w, "# Flakeguard Summary\n\n")
291328
// Print settings data
329+
printSeparator()
292330
printRow(rows[0])
293331
printSeparator()
294332
for _, row := range rows[1:] {

0 commit comments

Comments
 (0)