Skip to content

Commit f40257c

Browse files
committed
test(windows): fix launcher fallback fixtures
1 parent af3d3b1 commit f40257c

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

tests/cli_integration_test.zig

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn writeBrokenBareWindowsCodex(dir: fs.Dir) !void {
236236
});
237237
}
238238

239-
fn writeSuccessfulFakeCodexPowerShell(dir: fs.Dir) !void {
239+
fn writeSuccessfulFakeCodexPowerShellAt(dir: fs.Dir, sub_path: []const u8) !void {
240240
if (builtin.os.tag != .windows) return;
241241

242242
const script =
@@ -249,21 +249,34 @@ fn writeSuccessfulFakeCodexPowerShell(dir: fs.Dir) !void {
249249
"if (-not (Test-Path -LiteralPath $codexHomeDir)) { New-Item -ItemType Directory -Path $codexHomeDir | Out-Null }\r\n" ++
250250
"Copy-Item -Force (Join-Path $homePath 'fake-auth.json') (Join-Path $codexHomeDir 'auth.json')\r\n";
251251

252-
try dir.writeFile(.{ .sub_path = fakeCodexPowerShellPath(), .data = script });
252+
try dir.writeFile(.{ .sub_path = sub_path, .data = script });
253253
}
254254

255-
fn writeSuccessfulFakeCodexExe(
255+
fn writeSuccessfulFakeCodexPowerShell(dir: fs.Dir) !void {
256+
try writeSuccessfulFakeCodexPowerShellAt(dir, fakeCodexPowerShellPath());
257+
}
258+
259+
fn writeSuccessfulFakeCodexExeAt(
256260
allocator: std.mem.Allocator,
257261
dir: fs.Dir,
258262
project_root: []const u8,
263+
sub_path: []const u8,
259264
) !void {
260265
if (builtin.os.tag != .windows) return;
261266

262267
const built_fake_codex = try builtFakeCodexPathAlloc(allocator, project_root);
263268
defer allocator.free(built_fake_codex);
264269
const fake_codex_data = try fixtures.readFileAlloc(allocator, built_fake_codex);
265270
defer allocator.free(fake_codex_data);
266-
try dir.writeFile(.{ .sub_path = fakeCodexExePath(), .data = fake_codex_data });
271+
try dir.writeFile(.{ .sub_path = sub_path, .data = fake_codex_data });
272+
}
273+
274+
fn writeSuccessfulFakeCodexExe(
275+
allocator: std.mem.Allocator,
276+
dir: fs.Dir,
277+
project_root: []const u8,
278+
) !void {
279+
try writeSuccessfulFakeCodexExeAt(allocator, dir, project_root, fakeCodexExePath());
267280
}
268281

269282
fn fakeCurlCommandPath() []const u8 {
@@ -1103,13 +1116,8 @@ test "Scenario: Given an earlier PowerShell launcher and a later exe launcher wh
11031116
try tmp.dir.writeFile(.{ .sub_path = "fake-auth.json", .data = fake_auth });
11041117
try tmp.dir.writeFile(.{ .sub_path = "ps1-bin/codex", .data = "#!/bin/sh\nexit 99\n" });
11051118

1106-
const ps1_dir = try tmp.dir.openDir("ps1-bin", .{});
1107-
defer ps1_dir.close();
1108-
try writeSuccessfulFakeCodexPowerShell(ps1_dir);
1109-
1110-
const exe_dir = try tmp.dir.openDir("exe-bin", .{});
1111-
defer exe_dir.close();
1112-
try writeSuccessfulFakeCodexExe(gpa, exe_dir, project_root);
1119+
try writeSuccessfulFakeCodexPowerShellAt(tmp.dir, "ps1-bin/codex.ps1");
1120+
try writeSuccessfulFakeCodexExeAt(gpa, tmp.dir, project_root, "exe-bin/codex.exe");
11131121

11141122
const ps1_bin_path = try fs.path.join(gpa, &[_][]const u8{ home_root, "ps1-bin" });
11151123
defer gpa.free(ps1_bin_path);

0 commit comments

Comments
 (0)