authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-31 18:28:51-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 00:27:08-08:00
logf9585ad01fb1c5709fe448128b1a75cdf3597575
tree99d1ada771cbf8d0880d644955a6454a8058b4e7
parent9009ab2495a6f6c7eaa990d87986f32c85360667

update tests and tools to new main API


11 files changed, 33 insertions(+), 106 deletions(-)

test/standalone/dirname/exists_in.zig+2-10
......@@ -11,16 +11,8 @@
1111
1212const std = @import("std");
1313
14pub fn main() !void {
15 var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
16 const arena = arena_state.allocator();
17 defer arena_state.deinit();
18
19 try run(arena);
20}
21
22fn run(allocator: std.mem.Allocator) !void {
23 var args = try std.process.argsWithAllocator(allocator);
14pub fn main(init: std.process.Init) !void {
15 var args = try init.args.iterateAllocator(init.arena);
2416 defer args.deinit();
2517 _ = args.next() orelse unreachable; // skip binary name
2618
test/standalone/dirname/has_basename.zig+2-10
......@@ -13,16 +13,8 @@
1313
1414const std = @import("std");
1515
16pub fn main() !void {
17 var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
18 const arena = arena_state.allocator();
19 defer arena_state.deinit();
20
21 try run(arena);
22}
23
24fn run(allocator: std.mem.Allocator) !void {
25 var args = try std.process.argsWithAllocator(allocator);
16pub fn main(init: std.process.Init) !void {
17 var args = try init.args.iterateAllocator(init.arena);
2618 defer args.deinit();
2719 _ = args.next() orelse unreachable; // skip binary name
2820
test/standalone/dirname/touch.zig+2-10
......@@ -8,16 +8,8 @@
88
99const std = @import("std");
1010
11pub fn main() !void {
12 var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
13 const arena = arena_state.allocator();
14 defer arena_state.deinit();
15
16 try run(arena);
17}
18
19fn run(allocator: std.mem.Allocator) !void {
20 var args = try std.process.argsWithAllocator(allocator);
11pub fn main(init: std.process.Init) !void {
12 var args = try init.args.iterateAllocator(init.arena);
2113 defer args.deinit();
2214 _ = args.next() orelse unreachable; // skip binary name
2315
tools/dump-cov.zig+5-14
......@@ -8,20 +8,11 @@ const Path = std.Build.Cache.Path;
88const assert = std.debug.assert;
99const SeenPcsHeader = std.Build.abi.fuzz.SeenPcsHeader;
1010
11pub fn main() !void {
12 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
13 defer _ = debug_allocator.deinit();
14 const gpa = debug_allocator.allocator();
15
16 var arena_instance: std.heap.ArenaAllocator = .init(gpa);
17 defer arena_instance.deinit();
18 const arena = arena_instance.allocator();
19
20 var threaded: Io.Threaded = .init(gpa, .{});
21 defer threaded.deinit();
22 const io = threaded.io();
23
24 const args = try std.process.argsAlloc(arena);
11pub fn main(init: std.process.Init) !void {
12 const gpa = init.gpa;
13 const arena = init.arena;
14 const io = init.io;
15 const args = try init.args.toSlice(arena);
2516
2617 const target_query_str = switch (args.len) {
2718 3 => "native",
tools/fetch_them_macos_headers.zig+3-6
......@@ -66,12 +66,9 @@ const usage =
6666 \\-h, --help Print this help and exit
6767;
6868
69pub fn main() anyerror!void {
70 var arena = std.heap.ArenaAllocator.init(gpa);
71 defer arena.deinit();
72 const allocator = arena.allocator();
73
74 const args = try std.process.argsAlloc(allocator);
69pub fn main(init: std.process.Init) !void {
70 const allocator = init.arena;
71 const args = try init.args.toSlice(allocator);
7572
7673 var argv = std.array_list.Managed([]const u8).init(allocator);
7774 var sysroot: ?[]const u8 = null;
tools/gen_macos_headers_c.zig+4-12
......@@ -6,9 +6,6 @@ const info = std.log.info;
66const fatal = std.process.fatal;
77const Allocator = std.mem.Allocator;
88
9var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
10const gpa = general_purpose_allocator.allocator();
11
129const usage =
1310 \\gen_macos_headers_c [dir]
1411 \\
......@@ -16,16 +13,11 @@ const usage =
1613 \\-h, --help Print this help and exit
1714;
1815
19pub fn main() anyerror!void {
20 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
21 defer arena_allocator.deinit();
22 const arena = arena_allocator.allocator();
23
24 var threaded: Io.Threaded = .init(gpa, .{});
25 defer threaded.deinit();
26 const io = threaded.io();
16pub fn main(init: std.process.Init) !void {
17 const arena = init.arena;
18 const io = init.io;
2719
28 const args = try std.process.argsAlloc(arena);
20 const args = try init.args.toSlice(arena);
2921 if (args.len == 1) fatal("no command or option specified", .{});
3022
3123 var positionals = std.array_list.Managed([]const u8).init(arena);
tools/gen_outline_atomics.zig+3-8
......@@ -11,14 +11,9 @@ const AtomicOp = enum {
1111 ldset,
1212};
1313
14pub fn main() !void {
15 var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
16 defer arena_instance.deinit();
17 const arena = arena_instance.allocator();
18
19 var threaded: std.Io.Threaded = .init(arena, .{});
20 defer threaded.deinit();
21 const io = threaded.io();
14pub fn main(init: std.process.Init) !void {
15 const arena = init.arena;
16 const io = init.io;
2217
2318 //const args = try std.process.argsAlloc(arena);
2419
tools/generate_JSONTestSuite.zig+3-7
......@@ -3,13 +3,9 @@
33const std = @import("std");
44const Io = std.Io;
55
6pub fn main() !void {
7 var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
8 var allocator = gpa.allocator();
9
10 var threaded: std.Io.Threaded = .init(allocator, .{});
11 defer threaded.deinit();
12 const io = threaded.io();
6pub fn main(init: std.process.Init) !void {
7 const allocator = init.gpa;
8 const io = init.io;
139
1410 var stdout_buffer: [2000]u8 = undefined;
1511 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
tools/generate_c_size_and_align_checks.zig+3-10
......@@ -28,22 +28,15 @@ fn cName(ty: std.Target.CType) []const u8 {
2828
2929var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
3030
31pub fn main() !void {
32 const gpa = general_purpose_allocator.allocator();
33 defer std.debug.assert(general_purpose_allocator.deinit() == .ok);
34
35 const args = try std.process.argsAlloc(gpa);
36 defer std.process.argsFree(gpa, args);
31pub fn main(init: std.process.Init) !void {
32 const args = try init.args.toSlice(init.arena);
33 const io = init.io;
3734
3835 if (args.len != 2) {
3936 std.debug.print("Usage: {s} [target_triple]\n", .{args[0]});
4037 std.process.exit(1);
4138 }
4239
43 var threaded: std.Io.Threaded = .init(gpa, .{});
44 defer threaded.deinit();
45 const io = threaded.io();
46
4740 const query = try std.Target.Query.parse(.{ .arch_os_abi = args[1] });
4841 const target = try std.zig.system.resolveTargetQuery(io, query);
4942
tools/generate_linux_syscalls.zig+3-8
......@@ -170,14 +170,9 @@ const architectures: []const Arch = &.{
170170 // .{ .@"var" = "Microblaze", .table = .{ .specific = "arch/microblaze/kernel/syscalls/syscall.tbl" } },
171171};
172172
173pub fn main() !void {
174 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
175 defer arena.deinit();
176 const gpa = arena.allocator();
177
178 var threaded: Io.Threaded = .init(gpa, .{});
179 defer threaded.deinit();
180 const io = threaded.io();
173pub fn main(init: std.process.Init) !void {
174 const gpa = init.gpa;
175 const io = init.io;
181176
182177 const args = try std.process.argsAlloc(gpa);
183178 if (args.len < 2 or mem.eql(u8, args[1], "--help")) {
tools/incr-check.zig+3-11
......@@ -27,18 +27,10 @@ fn logImpl(
2727 );
2828}
2929
30pub fn main() !void {
30pub fn main(init: std.process.Init) !void {
3131 const fatal = std.process.fatal;
32
33 var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
34 defer arena_instance.deinit();
35 const arena = arena_instance.allocator();
36
37 const gpa = arena;
38
39 var threaded: Io.Threaded = .init(gpa, .{});
40 defer threaded.deinit();
41 const io = threaded.io();
32 const arena = init.arena;
33 const io = init.io;
4234
4335 var opt_zig_exe: ?[]const u8 = null;
4436 var opt_input_file_name: ?[]const u8 = null;