ReviewOS

also looking at this

zig-utils/zig-test-framework

test: make CI exercise maintained integrations

#18
Merged glennmichael123 wants to merge codex/issue-3-test-coverage into main
16 files +390 -139
tests/hooks_test.zigmodified+15-6
Changes to tests/hooks_test.zig
@@ -208,13 +208,21 @@ pub fn main() !void {
208208 }
209209 }.testSuite);
210210
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;
213214 var test_ran: bool = false;
214215
215216 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 };
218226 }
219227
220228 fn failingBefore(alloc: std.mem.Allocator) !void {
@@ -222,9 +230,10 @@ pub fn main() !void {
222230 return error.BeforeEachFailed;
223231 }
224232
225 fn testThatShouldntRun(alloc: std.mem.Allocator) !void {
226 _ = alloc;
233 fn testAfterRecovery(alloc: std.mem.Allocator) !void {
227234 test_ran = true;
235 try ztf.expect(alloc, hook_failure_observed).toBe(true);
236 try ztf.expect(alloc, test_ran).toBe(true);
228237 }
229238 }.testSuite);
230239