commit 1b56686012c49b34f395c82741b03587633aaa31 (tree)
parent f2cf7b538f5c8ec0da69715d39ad6d433f3168d6
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 1 Jan 2026 23:52:26 -0800
test-standalone: update cases to new main API
Diffstat:
10 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/lib/compiler/resinator/main.zig b/lib/compiler/resinator/main.zig
@@ -24,7 +24,10 @@ pub fn main(init: std.process.Init.Minimal) !void {
defer std.debug.assert(debug_allocator.deinit() == .ok);
const gpa = debug_allocator.allocator();
- var threaded: std.Io.Threaded = .init(gpa, .{});
+ var threaded: std.Io.Threaded = .init(gpa, .{
+ .environ = init.environ,
+ .argv0 = .init(init.args),
+ });
defer threaded.deinit();
const io = threaded.io();
@@ -536,13 +539,24 @@ const LazyIncludePaths = struct {
target_machine_type: std.coff.IMAGE.FILE.MACHINE,
resolved_include_paths: ?[]const []const u8 = null,
- pub fn get(self: *LazyIncludePaths, error_handler: *ErrorHandler) ![]const []const u8 {
+ pub fn get(
+ self: *LazyIncludePaths,
+ error_handler: *ErrorHandler,
+ env_map: *const std.process.Environ.Map,
+ ) ![]const []const u8 {
const io = self.io;
if (self.resolved_include_paths) |include_paths|
return include_paths;
- return getIncludePaths(self.arena, io, self.auto_includes_option, self.zig_lib_dir, self.target_machine_type) catch |err| switch (err) {
+ return getIncludePaths(
+ self.arena,
+ io,
+ self.auto_includes_option,
+ self.zig_lib_dir,
+ self.target_machine_type,
+ env_map,
+ ) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
else => |e| {
switch (e) {
@@ -569,6 +583,7 @@ fn getIncludePaths(
auto_includes_option: cli.Options.AutoIncludes,
zig_lib_dir: []const u8,
target_machine_type: std.coff.IMAGE.FILE.MACHINE,
+ env_map: *const std.process.Environ.Map,
) ![]const []const u8 {
if (auto_includes_option == .none) return &[_][]const u8{};
@@ -641,7 +656,16 @@ fn getIncludePaths(
};
const target = std.zig.resolveTargetQueryOrFatal(io, target_query);
const is_native_abi = target_query.isNativeAbi();
- const detected_libc = std.zig.LibCDirs.detect(arena, io, zig_lib_dir, &target, is_native_abi, true, null) catch |err| switch (err) {
+ const detected_libc = std.zig.LibCDirs.detect(
+ arena,
+ io,
+ zig_lib_dir,
+ &target,
+ is_native_abi,
+ true,
+ null,
+ env_map,
+ ) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
else => return error.MingwIncludesNotFound,
};
diff --git a/lib/compiler/translate-c/main.zig b/lib/compiler/translate-c/main.zig
@@ -25,8 +25,8 @@ pub fn main(init: std.process.Init) u8 {
zig_integration = true;
}
- const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet();
- const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet();
+ const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(init.env_map);
+ const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(init.env_map);
var stderr_buf: [1024]u8 = undefined;
var stderr = Io.File.stderr().writer(io, &stderr_buf);
diff --git a/test/standalone/coff_dwarf/main.zig b/test/standalone/coff_dwarf/main.zig
@@ -3,18 +3,13 @@ const fatal = std.process.fatal;
extern fn add(a: u32, b: u32, addr: *usize) u32;
-pub fn main() void {
- var debug_alloc_inst: std.heap.DebugAllocator(.{}) = .init;
- defer std.debug.assert(debug_alloc_inst.deinit() == .ok);
- const gpa = debug_alloc_inst.allocator();
+pub fn main(init: std.process.Init) void {
+ const gpa = init.gpa;
+ const io = init.io;
var di: std.debug.SelfInfo = .init;
defer di.deinit(gpa);
- var threaded: std.Io.Threaded = .init(gpa, .{});
- defer threaded.deinit();
- const io = threaded.io();
-
var add_addr: usize = undefined;
_ = add(1, 2, &add_addr);
diff --git a/test/standalone/dirname/exists_in.zig b/test/standalone/dirname/exists_in.zig
@@ -12,7 +12,7 @@
const std = @import("std");
pub fn main(init: std.process.Init) !void {
- var args = try init.args.iterateAllocator(init.arena);
+ var args = try init.minimal.args.iterateAllocator(init.gpa);
defer args.deinit();
_ = args.next() orelse unreachable; // skip binary name
diff --git a/test/standalone/dirname/has_basename.zig b/test/standalone/dirname/has_basename.zig
@@ -14,7 +14,7 @@
const std = @import("std");
pub fn main(init: std.process.Init) !void {
- var args = try init.args.iterateAllocator(init.arena);
+ var args = try init.minimal.args.iterateAllocator(init.gpa);
defer args.deinit();
_ = args.next() orelse unreachable; // skip binary name
diff --git a/test/standalone/dirname/touch.zig b/test/standalone/dirname/touch.zig
@@ -9,7 +9,7 @@
const std = @import("std");
pub fn main(init: std.process.Init) !void {
- var args = try init.args.iterateAllocator(init.arena);
+ var args = try init.minimal.args.iterateAllocator(init.gpa);
defer args.deinit();
_ = args.next() orelse unreachable; // skip binary name
diff --git a/test/standalone/load_dynamic_library/main.zig b/test/standalone/load_dynamic_library/main.zig
@@ -1,10 +1,7 @@
const std = @import("std");
-pub fn main() !void {
- var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
- defer _ = gpa.deinit();
- const args = try std.process.argsAlloc(gpa.allocator());
- defer std.process.argsFree(gpa.allocator(), args);
+pub fn main(init: std.process.Init) !void {
+ const args = try init.minimal.args.toSlice(init.arena.allocator());
const dynlib_name = args[1];
diff --git a/test/standalone/posix/cwd.zig b/test/standalone/posix/cwd.zig
@@ -7,24 +7,16 @@ const assert = std.debug.assert;
const path_max = std.fs.max_path_bytes;
-pub fn main() !void {
+pub fn main(init: std.process.Init) !void {
switch (builtin.target.os.tag) {
.wasi => return, // WASI doesn't support changing the working directory at all.
.windows => return, // POSIX is not implemented by Windows
else => {},
}
- var debug_allocator: std.heap.DebugAllocator(.{}) = .{};
- defer assert(debug_allocator.deinit() == .ok);
- const gpa = debug_allocator.allocator();
-
- var threaded: std.Io.Threaded = .init(gpa, .{});
- defer threaded.deinit();
- const io = threaded.io();
-
try test_chdir_self();
try test_chdir_absolute();
- try test_chdir_relative(gpa, io);
+ try test_chdir_relative(init.gpa, init.io);
}
// get current working directory and expect it to match given path
diff --git a/test/standalone/posix/relpaths.zig b/test/standalone/posix/relpaths.zig
@@ -6,16 +6,10 @@ const builtin = @import("builtin");
const std = @import("std");
const Io = std.Io;
-pub fn main() !void {
+pub fn main(init: std.process.Init) !void {
if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir
- var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
- const gpa = debug_allocator.allocator();
- defer std.debug.assert(debug_allocator.deinit() == .ok);
-
- var threaded: std.Io.Threaded = .init(gpa, .{});
- defer threaded.deinit();
- const io = threaded.io();
+ const io = init.io;
var tmp = tmpDir(io, .{});
defer tmp.cleanup(io);
diff --git a/test/standalone/run_cwd/check_file_exists.zig b/test/standalone/run_cwd/check_file_exists.zig
@@ -1,9 +1,6 @@
-pub fn main() !void {
- var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
- defer arena_state.deinit();
- const arena = arena_state.allocator();
-
- const args = try std.process.argsAlloc(arena);
+pub fn main(init: std.process.Init) !void {
+ const arena = init.arena.allocator();
+ const args = try init.minimal.args.toSlice(arena);
if (args.len != 2) return error.BadUsage;
const path = args[1];