Skip to content

Commit 63eefaa

Browse files
authored
Flakeguard: Enhance test results (#1723)
1 parent 7f68870 commit 63eefaa

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

tools/flakeguard/cmd/run.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var RunTestsCmd = &cobra.Command{
185185
}
186186

187187
fmt.Fprint(&summaryBuffer, "\nFailed Tests On The First Run:\n\n")
188-
reports.PrintTestResultsTable(&summaryBuffer, failedTests, false, false, true, false)
188+
reports.PrintTestResultsTable(&summaryBuffer, failedTests, false, false, true, false, false, false)
189189
fmt.Fprintln(&summaryBuffer)
190190

191191
rerunResults, rerunJsonOutputPaths, err := testRunner.RerunFailedTests(failedTests, rerunFailedCount)
@@ -207,8 +207,8 @@ var RunTestsCmd = &cobra.Command{
207207
flushSummaryAndExit(ErrorExitCode)
208208
}
209209

210-
fmt.Fprint(&summaryBuffer, "\nFailed Tests After Rerun:\n\n")
211-
reports.PrintTestResultsTable(&summaryBuffer, rerunResults, false, false, true, true)
210+
fmt.Fprint(&summaryBuffer, "\nTests After Rerun:\n\n")
211+
reports.PrintTestResultsTable(&summaryBuffer, rerunResults, false, false, true, true, true, true)
212212
fmt.Fprintln(&summaryBuffer)
213213

214214
// Save the rerun test report to file
@@ -252,6 +252,9 @@ var RunTestsCmd = &cobra.Command{
252252
Int("count", len(flakyTests)).
253253
Str("stability threshold", fmt.Sprintf("%.0f%%", passRatioThreshold*100)).
254254
Msg("Found flaky tests")
255+
256+
fmt.Fprint(&summaryBuffer, "\nFlakeguard Summary\n")
257+
reports.RenderTestReport(&summaryBuffer, mainReport, false, false)
255258
flushSummaryAndExit(FlakyTestsExitCode)
256259
} else {
257260
log.Info().Msg("All tests passed stability requirements")

tools/flakeguard/reports/presentation.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func generateShortTestResultsTable(
7979
results []TestResult,
8080
markdown bool,
8181
showEverPassed bool,
82+
showRuns bool,
83+
showSuccesses bool,
8284
filter func(TestResult) bool,
8385
) [][]string {
8486
p := message.NewPrinter(language.English)
@@ -89,7 +91,14 @@ func generateShortTestResultsTable(
8991
if showEverPassed {
9092
headers = append(headers, "Ever Passed")
9193
}
92-
headers = append(headers, "Runs", "Successes", "Code Owners", "Path")
94+
if showRuns {
95+
headers = append(headers, "Runs")
96+
}
97+
if showSuccesses {
98+
headers = append(headers, "Successes")
99+
}
100+
101+
headers = append(headers, "Code Owners", "Path")
93102

94103
// Optionally format the headers for Markdown
95104
if markdown {
@@ -124,9 +133,14 @@ func generateShortTestResultsTable(
124133
if showEverPassed {
125134
row = append(row, passed)
126135
}
136+
if showRuns {
137+
row = append(row, p.Sprintf("%d", r.Runs))
138+
}
139+
if showSuccesses {
140+
row = append(row, p.Sprintf("%d", r.Successes))
141+
}
142+
127143
row = append(row,
128-
p.Sprintf("%d", r.Runs),
129-
p.Sprintf("%d", r.Successes),
130144
owners,
131145
r.TestPath,
132146
)
@@ -154,13 +168,15 @@ func PrintTestResultsTable(
154168
markdown bool,
155169
collapsible bool,
156170
shortTable bool,
157-
showEverPassed bool) {
171+
showEverPassed bool,
172+
showRuns bool,
173+
showSuccesses bool) {
158174
filter := func(result TestResult) bool {
159175
return true // Include all tests
160176
}
161177
var table [][]string
162178
if shortTable {
163-
table = generateShortTestResultsTable(results, markdown, showEverPassed, filter)
179+
table = generateShortTestResultsTable(results, markdown, showEverPassed, showRuns, showSuccesses, filter)
164180
} else {
165181
table = generateTestResultsTable(results, markdown, filter)
166182
}

0 commit comments

Comments
 (0)