authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-01 23:52:26-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 00:27:08-08:00
log1b56686012c49b34f395c82741b03587633aaa31
tree8e2e9b1020f48044796b56b84f9fe84dbbee45f1
parentf2cf7b538f5c8ec0da69715d39ad6d433f3168d6

test-standalone: update cases to new main API


10 files changed, 45 insertions(+), 46 deletions(-)

lib/compiler/resinator/main.zig+28-4
......@@ -24,7 +24,10 @@ pub fn main(init: std.process.Init.Minimal) !void {
2424 defer std.debug.assert(debug_allocator.deinit() == .ok);
2525 const gpa = debug_allocator.allocator();
2626
27 var threaded: std.Io.Threaded = .init(gpa, .{});
27 var threaded: std.Io.Threaded = .init(gpa, .{
28 .environ = init.environ,
29 .argv0 = .init(init.args),
30 });
2831 defer threaded.deinit();
2932 const io = threaded.io();
3033
......@@ -536,13 +539,24 @@ const LazyIncludePaths = struct {
536539 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
537540 resolved_include_paths: ?[]const []const u8 = null,
538541
539 pub fn get(self: *LazyIncludePaths, error_handler: *ErrorHandler) ![]const []const u8 {
542 pub fn get(
543 self: *LazyIncludePaths,
544 error_handler: *ErrorHandler,
545 env_map: *const std.process.Environ.Map,
546 ) ![]const []const u8 {
540547 const io = self.io;
541548
542549 if (self.resolved_include_paths) |include_paths|
543550 return include_paths;
544551
545 return getIncludePaths(self.arena, io, self.auto_includes_option, self.zig_lib_dir, self.target_machine_type) catch |err| switch (err) {
552 return getIncludePaths(
553 self.arena,
554 io,
555 self.auto_includes_option,
556 self.zig_lib_dir,
557 self.target_machine_type,
558 env_map,
559 ) catch |err| switch (err) {
546560 error.OutOfMemory => |e| return e,
547561 else => |e| {
548562 switch (e) {
......@@ -569,6 +583,7 @@ fn getIncludePaths(
569583 auto_includes_option: cli.Options.AutoIncludes,
570584 zig_lib_dir: []const u8,
571585 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
586 env_map: *const std.process.Environ.Map,
572587) ![]const []const u8 {
573588 if (auto_includes_option == .none) return &[_][]const u8{};
574589
......@@ -641,7 +656,16 @@ fn getIncludePaths(
641656 };
642657 const target = std.zig.resolveTargetQueryOrFatal(io, target_query);
643658 const is_native_abi = target_query.isNativeAbi();
644 const detected_libc = std.zig.LibCDirs.detect(arena, io, zig_lib_dir, &target, is_native_abi, true, null) catch |err| switch (err) {
659 const detected_libc = std.zig.LibCDirs.detect(
660 arena,
661 io,
662 zig_lib_dir,
663 &target,
664 is_native_abi,
665 true,
666 null,
667 env_map,
668 ) catch |err| switch (err) {
645669 error.OutOfMemory => |e| return e,
646670 else => return error.MingwIncludesNotFound,
647671 };
lib/compiler/translate-c/main.zig+2-2
......@@ -25,8 +25,8 @@ pub fn main(init: std.process.Init) u8 {
2525 zig_integration = true;
2626 }
2727
28 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet();
29 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet();
28 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(init.env_map);
29 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(init.env_map);
3030
3131 var stderr_buf: [1024]u8 = undefined;
3232 var stderr = Io.File.stderr().writer(io, &stderr_buf);
test/standalone/coff_dwarf/main.zig+3-8
......@@ -3,18 +3,13 @@ const fatal = std.process.fatal;
33
44extern fn add(a: u32, b: u32, addr: *usize) u32;
55
6pub fn main() void {
7 var debug_alloc_inst: std.heap.DebugAllocator(.{}) = .init;
8 defer std.debug.assert(debug_alloc_inst.deinit() == .ok);
9 const gpa = debug_alloc_inst.allocator();
6pub fn main(init: std.process.Init) void {
7 const gpa = init.gpa;
8 const io = init.io;
109
1110 var di: std.debug.SelfInfo = .init;
1211 defer di.deinit(gpa);
1312
14 var threaded: std.Io.Threaded = .init(gpa, .{});
15 defer threaded.deinit();
16 const io = threaded.io();
17
1813 var add_addr: usize = undefined;
1914 _ = add(1, 2, &add_addr);
2015
test/standalone/dirname/exists_in.zig+1-1
......@@ -12,7 +12,7 @@
1212const std = @import("std");
1313
1414pub fn main(init: std.process.Init) !void {
15 var args = try init.args.iterateAllocator(init.arena);
15 var args = try init.minimal.args.iterateAllocator(init.gpa);
1616 defer args.deinit();
1717 _ = args.next() orelse unreachable; // skip binary name
1818
test/standalone/dirname/has_basename.zig+1-1
......@@ -14,7 +14,7 @@
1414const std = @import("std");
1515
1616pub fn main(init: std.process.Init) !void {
17 var args = try init.args.iterateAllocator(init.arena);
17 var args = try init.minimal.args.iterateAllocator(init.gpa);
1818 defer args.deinit();
1919 _ = args.next() orelse unreachable; // skip binary name
2020
test/standalone/dirname/touch.zig+1-1
......@@ -9,7 +9,7 @@
99const std = @import("std");
1010
1111pub fn main(init: std.process.Init) !void {
12 var args = try init.args.iterateAllocator(init.arena);
12 var args = try init.minimal.args.iterateAllocator(init.gpa);
1313 defer args.deinit();
1414 _ = args.next() orelse unreachable; // skip binary name
1515
test/standalone/load_dynamic_library/main.zig+2-5
......@@ -1,10 +1,7 @@
11const std = @import("std");
22
3pub fn main() !void {
4 var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
5 defer _ = gpa.deinit();
6 const args = try std.process.argsAlloc(gpa.allocator());
7 defer std.process.argsFree(gpa.allocator(), args);
3pub fn main(init: std.process.Init) !void {
4 const args = try init.minimal.args.toSlice(init.arena.allocator());
85
96 const dynlib_name = args[1];
107
test/standalone/posix/cwd.zig+2-10
......@@ -7,24 +7,16 @@ const assert = std.debug.assert;
77
88const path_max = std.fs.max_path_bytes;
99
10pub fn main() !void {
10pub fn main(init: std.process.Init) !void {
1111 switch (builtin.target.os.tag) {
1212 .wasi => return, // WASI doesn't support changing the working directory at all.
1313 .windows => return, // POSIX is not implemented by Windows
1414 else => {},
1515 }
1616
17 var debug_allocator: std.heap.DebugAllocator(.{}) = .{};
18 defer assert(debug_allocator.deinit() == .ok);
19 const gpa = debug_allocator.allocator();
20
21 var threaded: std.Io.Threaded = .init(gpa, .{});
22 defer threaded.deinit();
23 const io = threaded.io();
24
2517 try test_chdir_self();
2618 try test_chdir_absolute();
27 try test_chdir_relative(gpa, io);
19 try test_chdir_relative(init.gpa, init.io);
2820}
2921
3022// get current working directory and expect it to match given path
test/standalone/posix/relpaths.zig+2-8
......@@ -6,16 +6,10 @@ const builtin = @import("builtin");
66const std = @import("std");
77const Io = std.Io;
88
9pub fn main() !void {
9pub fn main(init: std.process.Init) !void {
1010 if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir
1111
12 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
13 const gpa = debug_allocator.allocator();
14 defer std.debug.assert(debug_allocator.deinit() == .ok);
15
16 var threaded: std.Io.Threaded = .init(gpa, .{});
17 defer threaded.deinit();
18 const io = threaded.io();
12 const io = init.io;
1913
2014 var tmp = tmpDir(io, .{});
2115 defer tmp.cleanup(io);
test/standalone/run_cwd/check_file_exists.zig+3-6
......@@ -1,9 +1,6 @@
1pub fn main() !void {
2 var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
3 defer arena_state.deinit();
4 const arena = arena_state.allocator();
5
6 const args = try std.process.argsAlloc(arena);
1pub fn main(init: std.process.Init) !void {
2 const arena = init.arena.allocator();
3 const args = try init.minimal.args.toSlice(arena);
74
85 if (args.len != 2) return error.BadUsage;
96 const path = args[1];