Skip to content

Commit ec5a40a

Browse files
committed
Fixes reporting for Flakeguard aggregations
1 parent 436e956 commit ec5a40a

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

tools/flakeguard/Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ bench:
2424

2525
.PHONY: example
2626
example:
27-
rm -rf example_results
28-
mkdir -p example_results
29-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=Panic,Timeout --max-pass-ratio=1 --race=false --output-json=example_results/example_run_1.json
30-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=Panic,Timeout --max-pass-ratio=1 --race=false --output-json=example_results/example_run_2.json
31-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=Panic,Timeout --max-pass-ratio=1 --race=false --output-json=example_results/example_run_3.json
27+
./run_example.sh 3 TestPanic
3228
go run . aggregate-results \
3329
--results-path ./example_results \
3430
--output-path ./example_results \
@@ -56,11 +52,7 @@ example:
5652

5753
.PHONY: example_flaky_panic
5854
example_flaky_panic:
59-
rm -rf example_results
60-
mkdir -p example_results
61-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=TestPanic --max-pass-ratio=1 --race=false --output-json=example_results/example_run_1.json
62-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=TestPanic --max-pass-ratio=1 --race=false --output-json=example_results/example_run_2.json
63-
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --skip-tests=TestPanic --max-pass-ratio=1 --race=false --output-json=example_results/example_run_3.json
55+
./run_example.sh 3 TestPanic
6456
go run . aggregate-results \
6557
--results-path ./example_results \
6658
--output-path ./example_results \

tools/flakeguard/reports/data.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ type TestReport struct {
2828

2929
// GenerateSummaryData generates a summary of a report's test results
3030
func (testReport *TestReport) GenerateSummaryData() {
31-
var runs, mostRuns, passes, fails, skips, panickedTests, racedTests, flakyTests, skippedTests int
31+
var runs, testRunCount, passes, fails, skips, panickedTests, racedTests, flakyTests, skippedTests int
3232

3333
for _, result := range testReport.Results {
3434
runs += result.Runs
35-
if result.Runs > mostRuns {
36-
mostRuns = result.Runs
35+
if result.Runs > testRunCount {
36+
testRunCount = result.Runs
3737
}
3838
passes += result.Successes
3939
fails += result.Failures
@@ -67,7 +67,7 @@ func (testReport *TestReport) GenerateSummaryData() {
6767

6868
testReport.SummaryData = &SummaryData{
6969
UniqueTestsRun: totalTests,
70-
TestRunCount: mostRuns,
70+
TestRunCount: testRunCount,
7171
PanickedTests: panickedTests,
7272
RacedTests: racedTests,
7373
FlakyTests: flakyTests,

tools/flakeguard/reports/io.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ func LoadAndAggregate(resultsPath string, options ...AggregateOption) (*TestRepo
127127
}
128128

129129
// Apply options
130-
opts := aggregateOptions{}
130+
opts := aggregateOptions{
131+
maxPassRatio: 1.0,
132+
}
131133
for _, opt := range options {
132134
opt(&opts)
133135
}

tools/flakeguard/run_example.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
run_flakeguard() {
4+
local run_count=$1
5+
local skip_tests=$2
6+
7+
echo "Running Flakeguard $run_count times"
8+
9+
for ((i=1; i<=$run_count; i++)); do
10+
output_file="example_results/example_run_$i.json"
11+
go run . run \
12+
--project-path=./runner \
13+
--test-packages=./example_test_package \
14+
--run-count=5 \
15+
--skip-tests=$skip_tests \
16+
--max-pass-ratio=1 \
17+
--race=false \
18+
--output-json=$output_file
19+
local EXIT_CODE=$?
20+
if [ $EXIT_CODE -eq 2 ]; then
21+
echo "ERROR: Flakeguard encountered an error while running tests"
22+
exit $EXIT_CODE
23+
fi
24+
done
25+
}
26+
27+
# Run the commands
28+
rm -rf example_results
29+
mkdir -p example_results
30+
31+
run_flakeguard "$1" "$2"

0 commit comments

Comments
 (0)