Skip to content

Commit 606c6f1

Browse files
committed
Flake ratio
1 parent e8ad4b4 commit 606c6f1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tools/flakeguard/reports/reports.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,20 @@ func PrintTests(
240240
}
241241
}
242242

243-
var passRatioStr string
243+
var (
244+
passRatioStr string
245+
flakeRatioStr string
246+
)
244247
if runs == 0 || passes == runs {
245248
passRatioStr = "100%"
249+
flakeRatioStr = "0%"
246250
} else {
247-
percentage := float64(passes) / float64(runs) * 100
248-
truncatedPercentage := math.Floor(percentage*100) / 100 // Truncate to 2 decimal places
249-
passRatioStr = fmt.Sprintf("%.2f%%", truncatedPercentage)
251+
passPercentage := float64(passes) / float64(runs) * 100
252+
truncatedPassPercentage := math.Floor(passPercentage*100) / 100 // Truncate to 2 decimal places
253+
flakePercentage := float64(flakyTests) / float64(len(tests)) * 100
254+
truncatedFlakePercentage := math.Floor(flakePercentage*100) / 100 // Truncate to 2 decimal places
255+
passRatioStr = fmt.Sprintf("%.2f%%", truncatedPassPercentage)
256+
flakeRatioStr = fmt.Sprintf("%.2f%%", truncatedFlakePercentage)
250257
}
251258

252259
// Print out summary data
@@ -256,11 +263,12 @@ func PrintTests(
256263
{"**Panicked Tests**", fmt.Sprint(panickedTests)},
257264
{"**Raced Tests**", fmt.Sprint(racedTests)},
258265
{"**Flaky Tests**", fmt.Sprint(flakyTests)},
259-
{"**Pass Ratio**", passRatioStr},
266+
{"**Flaky Test Ratio**", flakeRatioStr},
260267
{"**Runs**", fmt.Sprint(runs)},
261268
{"**Passes**", fmt.Sprint(passes)},
262269
{"**Failures**", fmt.Sprint(fails)},
263270
{"**Skips**", fmt.Sprint(skips)},
271+
{"**Pass Ratio**", passRatioStr},
264272
}
265273
colWidths := make([]int, len(summaryData[0]))
266274

0 commit comments

Comments
 (0)