ReviewOS

also looking at this

zig-utils/zig-test-framework

Add retries, repeated runs, and flaky-test reporting

#25
Merged glennmichael123 wants to merge codex/issue-7-retries-repeat-flaky into main
15 files +719 -53
README.mdmodified+21-1
Changes to README.md
@@ -8,6 +8,7 @@ A modern, feature-rich testing framework for Zig inspired by Jest, Vitest, and B
88- **Code Coverage** - Line, branch, and function coverage with HTML reports (via kcov/grindcov)
99- **Async Test Support** - Full async test execution with concurrent and sequential modes
1010- **Timeout Handling** - Configurable timeouts at test, suite, and global levels with extension support
11- **Retries & Repeats** - Re-run failures, stress-run selected tests, and report flaky outcomes
1112- **Familiar API** - Describe/it syntax similar to Jest and Vitest
1213- **Rich Assertions** - Comprehensive assertion library with `.expect()` and matchers
1314- **Error Assertions** - `toThrow()` and `toThrowError()` for testing error handling
@@ -98,6 +99,9 @@ This will automatically discover and run all `*.test.zig` files in the `tests` d
9899- `--reporter <name>` - Use spec, dot, JSON, TAP, or JUnit output
99100- `--junit-output <file>` - Set the JUnit XML path
100101- `--timeout <ms>` - Mark files that exceed the global time budget as failed
102- `--retry <N>` - Retry a failed test or discovered test file up to N times
103- `--repeat <N>` - Require N successful repetitions of every selected test
104- `--fail-on-flaky` - Return a failing exit status when a retry recovers a failure
101105- `--shard-index <N>` - Run one one-based file shard
102106- `--shard-count <N>` - Set the total number of file shards
103107- `--no-color` - Disable color in child Zig test processes
@@ -125,6 +129,12 @@ zig-test --test-dir tests --no-recursive
125129# Stop on first failure
126130zig-test --test-dir tests --bail
127131
132# Retry failures twice and fail CI if any test is flaky
133zig-test --test-dir tests --retry 2 --fail-on-flaky
134
135# Stress-run matching tests 100 times
136zig-test --test-dir tests --filter parser --repeat 100
137
128138# Run the second of four deterministic file shards
129139zig-test --test-dir tests --shard-index 2 --shard-count 4
130140```
@@ -168,7 +178,10 @@ precedence over configured values.
168178 "test_dir": "tests",
169179 "pattern": "*.test.zig",
170180 "recursive": true,
171 "filter": "database"
181 "filter": "database",
182 "retries": 2,
183 "repeat": 10,
184 "fail_on_flaky": true
172185 },
173186 "sharding": {
174187 "index": 1,
@@ -185,6 +198,9 @@ The accepted top-level sections are `test`, `sharding`, `parallel`, `reporter`,
185198`snapshot`, `watch`, `memory`, `ui`, and `coverage`. Options retain the same execution-mode
186199limitations as their CLI equivalents; unsupported combinations fail explicitly.
187200
201See [Retries, repeats, and flaky tests](docs/retries-and-repeats.md) for attempt
202semantics, exit codes, reporter output, and programmatic configuration.
203
188204### Parallel execution semantics
189205
190206Programmatic runners can enable bounded execution with `RunnerOptions.parallel`
@@ -642,6 +658,9 @@ zig-test --no-color
642658| `--reporter <name>` | | Set reporter (spec, dot, json, tap, junit) |
643659| `--junit-output <file>` | | Set the JUnit XML output path |
644660| `--timeout <ms>` | | Set the global test timeout |
661| `--retry <N>` | `--retries <N>` | Retry each failed test up to N times |
662| `--repeat <N>` | | Require N successful runs of each selected test |
663| `--fail-on-flaky` | | Fail the run when a retry recovers a failure |
645664| `--verbose` | | Enable verbose output |
646665| `--quiet` | `-q` | Minimal output |
647666| `--no-color` | | Disable colored output |
@@ -921,6 +940,7 @@ MIT License - see [LICENSE](LICENSE) for details.
921940- [x] Memory profiling
922941- [x] Strict JSON configuration files
923942- [x] Parallel test execution
943- [x] Retries, repeated runs, and flaky-test reporting
924944- [ ] Parameterized tests (it.each)
925945- [ ] Property-based testing
926946- [ ] IDE integration