Skip to content

Commit 5c515ce

Browse files
committed
Add min-pass-ratio flag to aggregate-failed cmd
1 parent 82eefac commit 5c515ce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/flakeguard/cmd/aggregate_failed.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ var AggregateFailedCmd = &cobra.Command{
1717
resultsFolderPath, _ := cmd.Flags().GetString("results-path")
1818
outputPath, _ := cmd.Flags().GetString("output-json")
1919
threshold, _ := cmd.Flags().GetFloat64("threshold")
20+
minPassRatio, _ := cmd.Flags().GetFloat64("min-pass-ratio")
2021

2122
// Aggregate all test results
2223
allResults, err := reports.AggregateTestResults(resultsFolderPath)
2324
if err != nil {
2425
log.Fatalf("Error aggregating results: %v", err)
2526
}
2627

27-
// Filter to only include failed tests based on threshold
28+
// Filter to only include failed tests based on threshold and minPassRatio
2829
var failedResults []reports.TestResult
2930
for _, result := range allResults {
30-
if result.PassRatio < threshold && !result.Skipped {
31+
if result.PassRatio < threshold && result.PassRatio > minPassRatio && !result.Skipped {
3132
failedResults = append(failedResults, result)
3233
}
3334
}
@@ -39,7 +40,7 @@ var AggregateFailedCmd = &cobra.Command{
3940
}
4041
fmt.Printf("Filtered failed test results saved to %s\n", outputPath)
4142
} else {
42-
fmt.Println("No failed tests found based on the specified threshold.")
43+
fmt.Println("No failed tests found based on the specified threshold and min pass ratio.")
4344
}
4445
},
4546
}
@@ -48,6 +49,7 @@ func init() {
4849
AggregateFailedCmd.Flags().String("results-path", "testresult/", "Path to the folder containing JSON test result files")
4950
AggregateFailedCmd.Flags().String("output-json", "failed_tests.json", "Path to output the filtered failed test results in JSON format")
5051
AggregateFailedCmd.Flags().Float64("threshold", 0.8, "Threshold for considering a test as failed")
52+
AggregateFailedCmd.Flags().Float64("min-pass-ratio", 0.001, "Minimum pass ratio for considering a test as flaky. Used to distinguish between tests that are truly flaky (with inconsistent results) and those that are consistently failing.")
5153
}
5254

5355
// Helper function to save results to JSON file

0 commit comments

Comments
 (0)