zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 7366b4b9e2b9495ab79fd7edbf3d88dcbc8d6593 (tree)
parent bce3b1efb0879ba2f0da4d215c3190f3e8a4345b
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue, 23 Jul 2024 23:23:54 -0700

test runner: handle start_fuzzing message

Diffstat:
Mlib/compiler/test_runner.zig | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/lib/compiler/test_runner.zig b/lib/compiler/test_runner.zig @@ -128,6 +128,28 @@ fn mainServer() !void { }, }); }, + .start_fuzzing => { + const index = try server.receiveBody_u32(); + const test_fn = builtin.test_functions[index]; + while (true) { + testing.allocator_instance = .{}; + defer if (testing.allocator_instance.deinit() == .leak) std.process.exit(1); + log_err_count = 0; + is_fuzz_test = false; + test_fn.func() catch |err| switch (err) { + error.SkipZigTest => continue, + else => { + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace.*); + } + std.debug.print("failed with error.{s}\n", .{@errorName(err)}); + std.process.exit(1); + }, + }; + if (!is_fuzz_test) @panic("missed call to std.testing.fuzzInput"); + if (log_err_count != 0) @panic("error logs detected"); + } + }, else => { std.debug.print("unsupported message: {x}\n", .{@intFromEnum(hdr.tag)});