rename env_map to environ_map

For naming consistency with `std.process.Environ.Map`.
This commit is contained in:
Andrew Kelley
2026-01-02 21:57:47 -08:00
parent f25de4c7a2
commit 1070c2a71a
37 changed files with 290 additions and 291 deletions
+3 -3
View File
@@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
const process_cwd_path = try std.process.getCwdAlloc(gpa);
defer gpa.free(process_cwd_path);
var env_map = try init.environ.createMap(gpa);
defer env_map.deinit();
var environ_map = try init.environ.createMap(gpa);
defer environ_map.deinit();
var it = try init.args.iterateAllocator(gpa);
defer it.deinit();
@@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
const cwd_path = it.next() orelse break :child_path .{ child_path, false };
// If there is a third argument, it is the current CWD somewhere within the cache directory.
// In that case, modify the child path in order to test spawning a path with a leading `..` component.
break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &env_map, cwd_path, child_path), true };
break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &environ_map, cwd_path, child_path), true };
};
defer if (needs_free) gpa.free(child_path);
+1 -1
View File
@@ -1,5 +1,5 @@
const std = @import("std");
pub fn main(init: std.process.Init) !void {
try std.testing.expectEqual(0, init.env_map.count());
try std.testing.expectEqual(0, init.environ_map.count());
}
+14 -14
View File
@@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void {
// Environ.Map
{
var env_map = try environ.createMap(allocator);
defer env_map.deinit();
var environ_map = try environ.createMap(allocator);
defer environ_map.deinit();
try std.testing.expectEqualSlices(u8, "123", env_map.get("FOO").?);
try std.testing.expectEqual(null, env_map.get("FO"));
try std.testing.expectEqual(null, env_map.get("FOOO"));
try std.testing.expectEqualSlices(u8, "123", environ_map.get("FOO").?);
try std.testing.expectEqual(null, environ_map.get("FO"));
try std.testing.expectEqual(null, environ_map.get("FOOO"));
if (builtin.os.tag == .windows) {
try std.testing.expectEqualSlices(u8, "123", env_map.get("foo").?);
try std.testing.expectEqualSlices(u8, "123", environ_map.get("foo").?);
}
try std.testing.expectEqualSlices(u8, "ABC=123", env_map.get("EQUALS").?);
try std.testing.expectEqual(null, env_map.get("EQUALS=ABC"));
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("КИРиллИЦА").?);
try std.testing.expectEqualSlices(u8, "ABC=123", environ_map.get("EQUALS").?);
try std.testing.expectEqual(null, environ_map.get("EQUALS=ABC"));
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("КИРиллИЦА").?);
if (builtin.os.tag == .windows) {
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("кирИЛЛица").?);
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("кирИЛЛица").?);
}
try std.testing.expectEqualSlices(u8, "", env_map.get("NO_VALUE").?);
try std.testing.expectEqual(null, env_map.get("NOT_SET"));
try std.testing.expectEqualSlices(u8, "", environ_map.get("NO_VALUE").?);
try std.testing.expectEqual(null, environ_map.get("NOT_SET"));
if (builtin.os.tag == .windows) {
try std.testing.expectEqualSlices(u8, "hi", env_map.get("=HIDDEN").?);
try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", env_map.get("INVALID_UTF16_\xed\xa0\x80").?);
try std.testing.expectEqualSlices(u8, "hi", environ_map.get("=HIDDEN").?);
try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", environ_map.get("INVALID_UTF16_\xed\xa0\x80").?);
}
}
}
@@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void {
const cwd = try std.process.getCwdAlloc(init.arena.allocator());
// If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`.
const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.env_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.environ_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
defer gpa.free(exe_rel_path);
try std.Io.Dir.cwd().symLink(io, exe_rel_path, symlink_path, .{});
+1 -1
View File
@@ -94,7 +94,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
const result = try std.process.run(gpa, io, .{
.env_map = env,
.environ_map = env,
.argv = argv,
});
defer gpa.free(result.stdout);
+1 -1
View File
@@ -141,7 +141,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
const result = try std.process.run(gpa, io, .{
.env_map = env,
.environ_map = env,
.argv = argv,
});
defer gpa.free(result.stdout);
+2 -2
View File
@@ -96,12 +96,12 @@ fn checkRelative(
expected_stdout: []const u8,
argv: []const []const u8,
cwd: ?[]const u8,
env_map: ?*const std.process.Environ.Map,
environ_map: ?*const std.process.Environ.Map,
) !void {
const result = try std.process.run(allocator, io, .{
.argv = argv,
.cwd = cwd,
.env_map = env_map,
.environ_map = environ_map,
});
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);