Zig 0.15: zig build test

This commit is contained in:
Mitchell Hashimoto
2025-10-01 13:10:40 -07:00
parent 3770f97608
commit cb295b84a0
66 changed files with 1264 additions and 1144 deletions

View File

@@ -26,7 +26,7 @@ pub const Options = struct {
// If it's not `-e` continue with the standard argument parsning.
if (!std.mem.eql(u8, arg, "-e")) return true;
var arguments: std.ArrayListUnmanaged([:0]const u8) = .empty;
var arguments: std.ArrayList([:0]const u8) = .empty;
errdefer {
for (arguments.items) |argument| alloc.free(argument);
arguments.deinit(alloc);
@@ -99,12 +99,21 @@ pub const Options = struct {
pub fn run(alloc: Allocator) !u8 {
var iter = try args.argsIterator(alloc);
defer iter.deinit();
return try runArgs(alloc, &iter);
var buffer: [1024]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&buffer);
const stderr = &stderr_writer.interface;
const result = runArgs(alloc, &iter, stderr);
stderr.flush() catch {};
return result;
}
fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
const stderr = std.io.getStdErr().writer();
fn runArgs(
alloc_gpa: Allocator,
argsIter: anytype,
stderr: *std.Io.Writer,
) !u8 {
var opts: Options = .{};
defer opts.deinit();
@@ -126,9 +135,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
inner: inline for (@typeInfo(Options).@"struct".fields) |field| {
if (field.name[0] == '_') continue :inner;
if (std.mem.eql(u8, field.name, diagnostic.key)) {
try stderr.writeAll("config error: ");
try diagnostic.write(stderr);
try stderr.writeAll("\n");
try stderr.print("config error: {f}\n", .{diagnostic});
exit = true;
}
}