also looking at this
test: make CI exercise maintained integrations
#18
16 files
+390
-139
| @@ -208,13 +208,21 @@ pub fn main() !void { | ||
| 208 | 208 | } |
| 209 | 209 | }.testSuite); |
| 210 | 210 | |
| 211 | // Test 5: Hook error handling | |
| 212 | try ztf.describe(allocator, "Hook error handling", struct { | |
| 211 | // Test 5: Hook error recovery | |
| 212 | try ztf.describe(allocator, "Hook error recovery", struct { | |
| 213 | var hook_failure_observed: bool = false; | |
| 213 | 214 | var test_ran: bool = false; |
| 214 | 215 | |
| 215 | 216 | fn testSuite(alloc: std.mem.Allocator) !void { |
| 216 | try ztf.beforeEach(alloc, failingBefore); | |
| 217 | try ztf.it(alloc, "this test should be skipped due to beforeEach failure", testThatShouldntRun); | |
| 217 | try ztf.beforeEach(alloc, recoverFromFailure); | |
| 218 | try ztf.it(alloc, "a wrapper hook can recover from an expected failure", testAfterRecovery); | |
| 219 | } | |
| 220 | ||
| 221 | fn recoverFromFailure(alloc: std.mem.Allocator) !void { | |
| 222 | failingBefore(alloc) catch |err| { | |
| 223 | if (err != error.BeforeEachFailed) return err; | |
| 224 | hook_failure_observed = true; | |
| 225 | }; | |
| 218 | 226 | } |
| 219 | 227 | |
| 220 | 228 | fn failingBefore(alloc: std.mem.Allocator) !void { |
| @@ -222,9 +230,10 @@ pub fn main() !void { | ||
| 222 | 230 | return error.BeforeEachFailed; |
| 223 | 231 | } |
| 224 | 232 | |
| 225 | fn testThatShouldntRun(alloc: std.mem.Allocator) !void { | |
| 226 | _ = alloc; | |
| 233 | fn testAfterRecovery(alloc: std.mem.Allocator) !void { | |
| 227 | 234 | test_ran = true; |
| 235 | try ztf.expect(alloc, hook_failure_observed).toBe(true); | |
| 236 | try ztf.expect(alloc, test_ran).toBe(true); | |
| 228 | 237 | } |
| 229 | 238 | }.testSuite); |
| 230 | 239 | |