also looking at this
Add retries, repeated runs, and flaky-test reporting
#25
15 files
+719
-53
| @@ -29,6 +29,9 @@ pub const TestOptions = struct { | ||
| 29 | 29 | recursive: bool = true, |
| 30 | 30 | filter: ?[]const u8 = null, |
| 31 | 31 | timeout: ?u64 = null, |
| 32 | retries: usize = 0, | |
| 33 | repeat: usize = 1, | |
| 34 | fail_on_flaky: bool = false, | |
| 32 | 35 | }; |
| 33 | 36 | |
| 34 | 37 | pub const ParallelOptions = struct { |
| @@ -86,6 +89,7 @@ pub const ConfigError = error{ | ||
| 86 | 89 | InvalidJobs, |
| 87 | 90 | InvalidPort, |
| 88 | 91 | InvalidTimeout, |
| 92 | InvalidRepeat, | |
| 89 | 93 | InvalidDebounce, |
| 90 | 94 | InvalidShard, |
| 91 | 95 | }; |
| @@ -183,6 +187,7 @@ fn validate(config: TestConfig) !void { | ||
| 183 | 187 | if (config.test_options.timeout) |timeout| { |
| 184 | 188 | if (timeout == 0) return ConfigError.InvalidTimeout; |
| 185 | 189 | } |
| 190 | if (config.test_options.repeat == 0) return ConfigError.InvalidRepeat; | |
| 186 | 191 | if (config.watch.debounce_ms == 0) return ConfigError.InvalidDebounce; |
| 187 | 192 | const has_shard_index = config.sharding.index != null; |
| 188 | 193 | const has_shard_count = config.sharding.count != null; |
| @@ -199,6 +204,9 @@ test "TestConfig defaults match CLI discovery defaults" { | ||
| 199 | 204 | try std.testing.expectEqualStrings(".", config.test_options.test_dir); |
| 200 | 205 | try std.testing.expect(config.test_options.recursive); |
| 201 | 206 | try std.testing.expect(config.test_options.timeout == null); |
| 207 | try std.testing.expectEqual(@as(usize, 0), config.test_options.retries); | |
| 208 | try std.testing.expectEqual(@as(usize, 1), config.test_options.repeat); | |
| 209 | try std.testing.expect(!config.test_options.fail_on_flaky); | |
| 202 | 210 | try std.testing.expect(config.sharding.index == null); |
| 203 | 211 | try std.testing.expect(config.sharding.count == null); |
| 204 | 212 | try std.testing.expect(!config.parallel.enabled); |
| @@ -219,6 +227,9 @@ test "configuration validation rejects invalid runtime values" { | ||
| 219 | 227 | invalid.parallel.jobs = 0; |
| 220 | 228 | try std.testing.expectError(ConfigError.InvalidJobs, validate(invalid)); |
| 221 | 229 | invalid.parallel.jobs = null; |
| 230 | invalid.test_options.repeat = 0; | |
| 231 | try std.testing.expectError(ConfigError.InvalidRepeat, validate(invalid)); | |
| 232 | invalid.test_options.repeat = 1; | |
| 222 | 233 | invalid.sharding.index = 2; |
| 223 | 234 | try std.testing.expectError(ConfigError.InvalidShard, validate(invalid)); |
| 224 | 235 | invalid.sharding.count = 1; |
| @@ -233,6 +244,9 @@ test "ConfigLoader loads supported JSON and rejects unknown keys" { | ||
| 233 | 244 | try std.testing.expectEqualStrings("tests/fixtures", config.test_options.test_dir); |
| 234 | 245 | try std.testing.expectEqualStrings("selected test passes", config.test_options.filter.?); |
| 235 | 246 | try std.testing.expect(!config.test_options.recursive); |
| 247 | try std.testing.expectEqual(@as(usize, 1), config.test_options.retries); | |
| 248 | try std.testing.expectEqual(@as(usize, 2), config.test_options.repeat); | |
| 249 | try std.testing.expect(!config.test_options.fail_on_flaky); | |
| 236 | 250 | try std.testing.expectEqual(@as(?usize, 1), config.sharding.index); |
| 237 | 251 | try std.testing.expectEqual(@as(?usize, 1), config.sharding.count); |
| 238 | 252 | |