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 {...@@ -24,7 +24,10 @@ pub fn main(init: std.process.Init.Minimal) !void {
24 defer std.debug.assert(debug_allocator.deinit() == .ok);24 defer std.debug.assert(debug_allocator.deinit() == .ok);
25 const gpa = debug_allocator.allocator();25 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 });
28 defer threaded.deinit();31 defer threaded.deinit();
29 const io = threaded.io();32 const io = threaded.io();
3033
...@@ -536,13 +539,24 @@ const LazyIncludePaths = struct {...@@ -536,13 +539,24 @@ const LazyIncludePaths = struct {
536 target_machine_type: std.coff.IMAGE.FILE.MACHINE,539 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
537 resolved_include_paths: ?[]const []const u8 = null,540 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 {
540 const io = self.io;547 const io = self.io;
541548
542 if (self.resolved_include_paths) |include_paths|549 if (self.resolved_include_paths) |include_paths|
543 return include_paths;550 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) {
546 error.OutOfMemory => |e| return e,560 error.OutOfMemory => |e| return e,
547 else => |e| {561 else => |e| {
548 switch (e) {562 switch (e) {
...@@ -569,6 +583,7 @@ fn getIncludePaths(...@@ -569,6 +583,7 @@ fn getIncludePaths(
569 auto_includes_option: cli.Options.AutoIncludes,583 auto_includes_option: cli.Options.AutoIncludes,
570 zig_lib_dir: []const u8,584 zig_lib_dir: []const u8,
571 target_machine_type: std.coff.IMAGE.FILE.MACHINE,585 target_machine_type: std.coff.IMAGE.FILE.MACHINE,
586 env_map: *const std.process.Environ.Map,
572) ![]const []const u8 {587) ![]const []const u8 {
573 if (auto_includes_option == .none) return &[_][]const u8{};588 if (auto_includes_option == .none) return &[_][]const u8{};
574589
...@@ -641,7 +656,16 @@ fn getIncludePaths(...@@ -641,7 +656,16 @@ fn getIncludePaths(
641 };656 };
642 const target = std.zig.resolveTargetQueryOrFatal(io, target_query);657 const target = std.zig.resolveTargetQueryOrFatal(io, target_query);
643 const is_native_abi = target_query.isNativeAbi();658 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) {
645 error.OutOfMemory => |e| return e,669 error.OutOfMemory => |e| return e,
646 else => return error.MingwIncludesNotFound,670 else => return error.MingwIncludesNotFound,
647 };671 };
lib/compiler/translate-c/main.zig+2-2
...@@ -25,8 +25,8 @@ pub fn main(init: std.process.Init) u8 {...@@ -25,8 +25,8 @@ pub fn main(init: std.process.Init) u8 {
25 zig_integration = true;25 zig_integration = true;
26 }26 }
2727
28 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet();28 const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(init.env_map);
29 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet();29 const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(init.env_map);
3030
31 var stderr_buf: [1024]u8 = undefined;31 var stderr_buf: [1024]u8 = undefined;
32 var stderr = Io.File.stderr().writer(io, &stderr_buf);32 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;...@@ -3,18 +3,13 @@ const fatal = std.process.fatal;
33
4extern fn add(a: u32, b: u32, addr: *usize) u32;4extern fn add(a: u32, b: u32, addr: *usize) u32;
55
6pub fn main() void {6pub fn main(init: std.process.Init) void {
7 var debug_alloc_inst: std.heap.DebugAllocator(.{}) = .init;7 const gpa = init.gpa;
8 defer std.debug.assert(debug_alloc_inst.deinit() == .ok);8 const io = init.io;
9 const gpa = debug_alloc_inst.allocator();
109
11 var di: std.debug.SelfInfo = .init;10 var di: std.debug.SelfInfo = .init;
12 defer di.deinit(gpa);11 defer di.deinit(gpa);
1312
14 var threaded: std.Io.Threaded = .init(gpa, .{});
15 defer threaded.deinit();
16 const io = threaded.io();
17
18 var add_addr: usize = undefined;13 var add_addr: usize = undefined;
19 _ = add(1, 2, &add_addr);14 _ = add(1, 2, &add_addr);
2015
test/standalone/dirname/exists_in.zig+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12const std = @import("std");12const std = @import("std");
1313
14pub fn main(init: std.process.Init) !void {14pub 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);
16 defer args.deinit();16 defer args.deinit();
17 _ = args.next() orelse unreachable; // skip binary name17 _ = args.next() orelse unreachable; // skip binary name
1818
test/standalone/dirname/has_basename.zig+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14const std = @import("std");14const std = @import("std");
1515
16pub fn main(init: std.process.Init) !void {16pub 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);
18 defer args.deinit();18 defer args.deinit();
19 _ = args.next() orelse unreachable; // skip binary name19 _ = args.next() orelse unreachable; // skip binary name
2020
test/standalone/dirname/touch.zig+1-1
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9const std = @import("std");9const std = @import("std");
1010
11pub fn main(init: std.process.Init) !void {11pub 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);
13 defer args.deinit();13 defer args.deinit();
14 _ = args.next() orelse unreachable; // skip binary name14 _ = args.next() orelse unreachable; // skip binary name
1515
test/standalone/load_dynamic_library/main.zig+2-5
...@@ -1,10 +1,7 @@...@@ -1,10 +1,7 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn main() !void {3pub fn main(init: std.process.Init) !void {
4 var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;4 const args = try init.minimal.args.toSlice(init.arena.allocator());
5 defer _ = gpa.deinit();
6 const args = try std.process.argsAlloc(gpa.allocator());
7 defer std.process.argsFree(gpa.allocator(), args);
85
9 const dynlib_name = args[1];6 const dynlib_name = args[1];
107
test/standalone/posix/cwd.zig+2-10
...@@ -7,24 +7,16 @@ const assert = std.debug.assert;...@@ -7,24 +7,16 @@ const assert = std.debug.assert;
77
8const path_max = std.fs.max_path_bytes;8const path_max = std.fs.max_path_bytes;
99
10pub fn main() !void {10pub fn main(init: std.process.Init) !void {
11 switch (builtin.target.os.tag) {11 switch (builtin.target.os.tag) {
12 .wasi => return, // WASI doesn't support changing the working directory at all.12 .wasi => return, // WASI doesn't support changing the working directory at all.
13 .windows => return, // POSIX is not implemented by Windows13 .windows => return, // POSIX is not implemented by Windows
14 else => {},14 else => {},
15 }15 }
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
25 try test_chdir_self();17 try test_chdir_self();
26 try test_chdir_absolute();18 try test_chdir_absolute();
27 try test_chdir_relative(gpa, io);19 try test_chdir_relative(init.gpa, init.io);
28}20}
2921
30// get current working directory and expect it to match given path22// 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");...@@ -6,16 +6,10 @@ const builtin = @import("builtin");
6const std = @import("std");6const std = @import("std");
7const Io = std.Io;7const Io = std.Io;
88
9pub fn main() !void {9pub fn main(init: std.process.Init) !void {
10 if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir10 if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir
1111
12 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;12 const io = init.io;
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();
1913
20 var tmp = tmpDir(io, .{});14 var tmp = tmpDir(io, .{});
21 defer tmp.cleanup(io);15 defer tmp.cleanup(io);
test/standalone/run_cwd/check_file_exists.zig+3-6
...@@ -1,9 +1,6 @@...@@ -1,9 +1,6 @@
1pub fn main() !void {1pub fn main(init: std.process.Init) !void {
2 var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);2 const arena = init.arena.allocator();
3 defer arena_state.deinit();3 const args = try init.minimal.args.toSlice(arena);
4 const arena = arena_state.allocator();
5
6 const args = try std.process.argsAlloc(arena);
74
8 if (args.len != 2) return error.BadUsage;5 if (args.len != 2) return error.BadUsage;
9 const path = args[1];6 const path = args[1];