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/suite_test.zigmodified+43-11
Changes to tests/suite_test.zig
@@ -1,19 +1,51 @@
11const std = ;
2const ztf = ;
23
3// Placeholder tests for suite module
4// TODO: Implement comprehensive tests for test suite management
4fn passingTest(_: std.mem.Allocator) !void {}
5fn hookOne(_: std.mem.Allocator) !void {}
6fn hookTwo(_: std.mem.Allocator) !void {}
57
6test "suite creation and management" {
7 // Test TestSuite initialization
8 try std.testing.expect(true);
8test "suite owns tests and nested suites" {
9 const allocator = std.testing.allocator;
10 const parent = try ztf.TestSuite.init(allocator, "parent");
11 defer parent.deinit();
12 const child = try ztf.TestSuite.init(allocator, "child");
13 try parent.addTest(ztf.TestCase.init("one", passingTest));
14 try child.addTest(ztf.TestCase.init("two", passingTest));
15 try parent.addSuite(child);
16 try std.testing.expectEqual(@as(usize, 2), parent.countTests());
17 try std.testing.expectEqual(parent, child.parent.?);
918}
1019
11test "suite nested describe blocks" {
12 // Test nested test suites
13 try std.testing.expect(true);
20test "nested hooks preserve before and after ordering" {
21 const allocator = std.testing.allocator;
22 const parent = try ztf.TestSuite.init(allocator, "parent");
23 defer parent.deinit();
24 const child = try ztf.TestSuite.init(allocator, "child");
25 try parent.addSuite(child);
26 try parent.addBeforeEach(hookOne);
27 try child.addBeforeEach(hookTwo);
28 try parent.addAfterEach(hookOne);
29 try child.addAfterEach(hookTwo);
30
31 var before = try child.getAllBeforeEachHooks(allocator);
32 defer before.deinit(allocator);
33 var after = try child.getAllAfterEachHooks(allocator);
34 defer after.deinit(allocator);
35 try std.testing.expectEqual(hookOne, before.items[0]);
36 try std.testing.expectEqual(hookTwo, before.items[1]);
37 try std.testing.expectEqual(hookTwo, after.items[0]);
38 try std.testing.expectEqual(hookOne, after.items[1]);
1439}
1540
16test "suite skip and only functionality" {
17 // Test skip and only modifiers
18 try std.testing.expect(true);
41test "suite skip and only state inherits from parents" {
42 const allocator = std.testing.allocator;
43 const parent = try ztf.TestSuite.init(allocator, "parent");
44 defer parent.deinit();
45 const child = try ztf.TestSuite.init(allocator, "child");
46 try parent.addSuite(child);
47 parent.skip = true;
48 parent.only = true;
49 try std.testing.expect(child.shouldSkip());
50 try std.testing.expect(child.hasOnly());
1951}