You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/flakeguard/Makefile
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,3 +7,30 @@ test:
7
7
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
8
8
set -euo pipefail
9
9
go list ./... | grep -v 'example_test_package'| xargs go test -json -cover -coverprofile unit-test-coverage.out -v 2>&1| tee /tmp/gotest.log | gotestfmt
10
+
11
+
.PHONY: example
12
+
example:
13
+
rm -rf example_results
14
+
mkdir -p example_results
15
+
- 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
16
+
- 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
17
+
- 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
18
+
go run . aggregate-results --results-path ./example_results --output-results ./example_results/all_tests_example.json
19
+
20
+
.PHONY: example_flaky_panic
21
+
example_flaky_panic:
22
+
rm -rf example_results
23
+
mkdir -p example_results
24
+
- 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
25
+
- 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
26
+
- 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
27
+
go run . aggregate-results --results-path ./example_results --output-results ./example_results/all_tests_example.json
28
+
29
+
.PHONY: example_timeout
30
+
example_timeout:
31
+
rm -rf example_results
32
+
mkdir -p example_results
33
+
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --select-tests=TestTimeout --timeout=1s --max-pass-ratio=1 --race=false --output-json=example_results/example_run_1.json
34
+
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --select-tests=TestTimeout --timeout=1s --max-pass-ratio=1 --race=false --output-json=example_results/example_run_2.json
35
+
- go run . run --project-path=./runner --test-packages=./example_test_package --run-count=5 --select-tests=TestTimeout --timeout=1s --max-pass-ratio=1 --race=false --output-json=example_results/example_run_3.json
36
+
go run . aggregate-results --results-path ./example_results --output-results ./example_results/all_tests_example.json
AggregateResultsCmd.Flags().StringVarP(&resultsFolderPath, "results-path", "p", "", "Path to the folder containing JSON test result files")
50
-
AggregateResultsCmd.Flags().StringVarP(&outputResultsPath, "output-results", "o", "./results.json", "Path to output the aggregated or filtered test results in JSON format")
51
+
AggregateResultsCmd.Flags().StringVarP(&outputResultsPath, "output-results", "o", "./results", "Path to output the aggregated or filtered test results in JSON and markdown format")
51
52
AggregateResultsCmd.Flags().StringVarP(&outputLogsPath, "output-logs", "l", "", "Path to output the filtered test logs in JSON format")
52
53
AggregateResultsCmd.Flags().Float64VarP(&maxPassRatio, "max-pass-ratio", "m", 1.0, "The maximum (non-inclusive) pass ratio threshold for a test to be considered a failure. Any tests below this pass rate will be considered flaky.")
53
54
AggregateResultsCmd.Flags().BoolVarP(&filterFailed, "filter-failed", "f", false, "If true, filter and output only failed tests based on the max-pass-ratio threshold")
fmt.Printf("No tests were run for the specified packages.\n")
97
95
}
98
96
},
@@ -104,12 +102,15 @@ func init() {
104
102
RunTestsCmd.Flags().StringSlice("test-packages", nil, "Comma-separated list of test packages to run")
105
103
RunTestsCmd.Flags().Bool("run-all-packages", false, "Run all test packages in the project. This flag overrides --test-packages and --test-packages-json")
106
104
RunTestsCmd.Flags().IntP("run-count", "c", 1, "Number of times to run the tests")
105
+
RunTestsCmd.Flags().Duration("timeout", 0, "Passed on to the 'go test' command as the -timeout flag")
106
+
RunTestsCmd.Flags().StringArray("tags", nil, "Passed on to the 'go test' command as the -tags flag")
107
107
RunTestsCmd.Flags().Bool("race", false, "Enable the race detector")
108
108
RunTestsCmd.Flags().Bool("shuffle", false, "Enable test shuffling")
109
109
RunTestsCmd.Flags().String("shuffle-seed", "", "Set seed for test shuffling. Must be used with --shuffle")
110
110
RunTestsCmd.Flags().Bool("fail-fast", false, "Stop on the first test failure")
111
111
RunTestsCmd.Flags().String("output-json", "", "Path to output the test results in JSON format")
112
112
RunTestsCmd.Flags().StringSlice("skip-tests", nil, "Comma-separated list of test names to skip from running")
113
+
RunTestsCmd.Flags().StringSlice("select-tests", nil, "Comma-separated list of test names to specifically run")
113
114
RunTestsCmd.Flags().Bool("print-failed-tests", true, "Print failed test results to the console")
114
115
RunTestsCmd.Flags().Float64("max-pass-ratio", 1.0, "The maximum (non-inclusive) pass ratio threshold for a test to be considered a failure. Any tests below this pass rate will be considered flaky.")
0 commit comments