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
examples/async_tests.zigmodified+12-12
Changes to examples/async_tests.zig
@@ -18,7 +18,7 @@ pub fn example_basic_async_test() !void {
1818 fn run(alloc: std.mem.Allocator) !void {
1919 _ = alloc;
2020 // Simulate async work
21 std.Thread.sleep(100 * std.time.ns_per_ms);
21 zig_test.compat.sleep(100 * std.time.ns_per_ms);
2222 std.debug.print("Async test 1 completed\n", .{});
2323 }
2424 }.run;
@@ -54,7 +54,7 @@ pub fn example_async_timeout() !void {
5454 const slowTest = struct {
5555 fn run(alloc: std.mem.Allocator) !void {
5656 _ = alloc;
57 std.Thread.sleep(500 * std.time.ns_per_ms); // Takes too long
57 zig_test.compat.sleep(500 * std.time.ns_per_ms); // Takes too long
5858 }
5959 }.run;
6060
@@ -87,7 +87,7 @@ pub fn example_concurrent_async() !void {
8787 const asyncTest = struct {
8888 fn run(alloc: std.mem.Allocator) !void {
8989 _ = alloc;
90 std.Thread.sleep(50 * std.time.ns_per_ms);
90 zig_test.compat.sleep(50 * std.time.ns_per_ms);
9191 }
9292 }.run;
9393
renamed throughout · 12 hidden lines
Changes to examples/async_tests.zig
@@ -97,10 +97,10 @@ pub fn example_concurrent_async() !void { renamed throughout
9797 try executor.registerTest("concurrent_4", asyncTest);
9898 try executor.registerTest("concurrent_5", asyncTest);
9999
100 const start = std.time.nanoTimestamp();
100 const start = zig_test.compat.nanoTimestamp();
101101 const results = try executor.executeAll();
102102 defer allocator.free(results);
103 const duration = std.time.nanoTimestamp() - start;
103 const duration = zig_test.compat.nanoTimestamp() - start;
104104
105105 std.debug.print("Total duration: {d:.2}ms\n", .{
106106 @as(f64, @floatFromInt(duration)) / 1_000_000.0,
Changes to examples/async_tests.zig
@@ -121,7 +121,7 @@ pub fn example_async_hooks() !void {
121121 fn run(alloc: std.mem.Allocator) !void {
122122 _ = alloc;
123123 std.debug.print("Before hook executed\n", .{});
124 std.Thread.sleep(10 * std.time.ns_per_ms);
124 zig_test.compat.sleep(10 * std.time.ns_per_ms);
125125 }
126126 }.run;
127127
@@ -129,7 +129,7 @@ pub fn example_async_hooks() !void {
129129 fn run(alloc: std.mem.Allocator) !void {
130130 _ = alloc;
131131 std.debug.print("After hook executed\n", .{});
132 std.Thread.sleep(10 * std.time.ns_per_ms);
132 zig_test.compat.sleep(10 * std.time.ns_per_ms);
133133 }
134134 }.run;
135135
@@ -150,7 +150,7 @@ pub fn example_suite_async() !void {
150150 const asyncTest1 = struct {
151151 fn run(alloc: std.mem.Allocator) !void {
152152 _ = alloc;
153 std.Thread.sleep(50 * std.time.ns_per_ms);
153 zig_test.compat.sleep(50 * std.time.ns_per_ms);
154154 std.debug.print("Suite async test 1 passed\n", .{});
155155 }
156156 }.run;
@@ -158,7 +158,7 @@ pub fn example_suite_async() !void {
158158 const asyncTest2 = struct {
159159 fn run(alloc: std.mem.Allocator) !void {
160160 _ = alloc;
161 std.Thread.sleep(50 * std.time.ns_per_ms);
161 zig_test.compat.sleep(50 * std.time.ns_per_ms);
162162 std.debug.print("Suite async test 2 passed\n", .{});
163163 }
164164 }.run;
@@ -187,7 +187,7 @@ pub fn example_mixed_tests() !void {
187187 const asyncTest = struct {
188188 fn run(alloc: std.mem.Allocator) !void {
189189 _ = alloc;
190 std.Thread.sleep(50 * std.time.ns_per_ms);
190 zig_test.compat.sleep(50 * std.time.ns_per_ms);
191191 std.debug.print("Async test executed\n", .{});
192192 }
193193 }.run;
@@ -212,7 +212,7 @@ pub fn example_async_errors() !void {
212212 const passingTest = struct {
213213 fn run(alloc: std.mem.Allocator) !void {
214214 _ = alloc;
215 std.Thread.sleep(10 * std.time.ns_per_ms);
215 zig_test.compat.sleep(10 * std.time.ns_per_ms);
216216 }
217217 }.run;
218218
@@ -220,7 +220,7 @@ pub fn example_async_errors() !void {
220220 const failingTest = struct {
221221 fn run(alloc: std.mem.Allocator) !void {
222222 _ = alloc;
223 std.Thread.sleep(10 * std.time.ns_per_ms);
223 zig_test.compat.sleep(10 * std.time.ns_per_ms);
224224 return error.AsyncTestFailed;
225225 }
226226 }.run;