Add process.Child.Cwd, use it for cwd and remove cwd_dir field

The user must now explicitly choose between inheriting the current CWD, passing a path for the CWD, or passing a Dir for the CWD.
This commit is contained in:
Ryan Liptak
2025-12-07 02:56:41 -08:00
parent 83abd73801
commit 05346e123b
13 changed files with 112 additions and 95 deletions
+6 -6
View File
@@ -199,7 +199,7 @@ fn printOutput(
if (expected_outcome == .build_fail) {
const result = try process.run(arena, io, .{
.argv = build_args.items,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
.environ_map = environ_map,
});
switch (result.term) {
@@ -255,7 +255,7 @@ fn printOutput(
const result = try process.run(arena, io, .{
.argv = run_args,
.environ_map = environ_map,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
});
switch (result.term) {
.exited => |exit_code| {
@@ -373,7 +373,7 @@ fn printOutput(
const result = try process.run(arena, io, .{
.argv = test_args.items,
.environ_map = environ_map,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
});
switch (result.term) {
.exited => |exit_code| {
@@ -428,7 +428,7 @@ fn printOutput(
const result = try process.run(arena, io, .{
.argv = test_args.items,
.environ_map = environ_map,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
});
switch (result.term) {
.exited => |exit_code| {
@@ -503,7 +503,7 @@ fn printOutput(
const result = try process.run(arena, io, .{
.argv = build_args.items,
.environ_map = environ_map,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
});
switch (result.term) {
.exited => |exit_code| {
@@ -1126,7 +1126,7 @@ fn run(
const result = try process.run(allocator, io, .{
.argv = args,
.environ_map = environ_map,
.cwd = cwd,
.cwd = .{ .path = cwd },
});
switch (result.term) {
.exited => |exit_code| {
+3 -6
View File
@@ -202,8 +202,7 @@ pub fn main(init: std.process.Init) !void {
.stdout = .pipe,
.stderr = .pipe,
.progress_node = zig_prog_node,
.cwd_dir = tmp_dir,
.cwd = tmp_dir_path,
.cwd = .{ .path = tmp_dir_path },
});
defer child.kill(io);
@@ -533,8 +532,7 @@ const Eval = struct {
const result = std.process.run(eval.arena, io, .{
.argv = argv,
.cwd_dir = eval.tmp_dir,
.cwd = eval.tmp_dir_path,
.cwd = .{ .path = eval.tmp_dir_path },
}) catch |err| {
if (is_foreign) {
// Chances are the foreign executor isn't available. Skip this evaluation.
@@ -626,8 +624,7 @@ const Eval = struct {
const result = std.process.run(eval.arena, eval.io, .{
.argv = eval.cc_child_args.items,
.cwd_dir = eval.tmp_dir,
.cwd = eval.tmp_dir_path,
.cwd = .{ .path = eval.tmp_dir_path },
.progress_node = child_prog_node,
}) catch |err| {
eval.fatal("failed to spawn zig cc for '{s}': {t}", .{ c_path, err });