Skip to content

Commit 4a562be

Browse files
committed
test: guard csh shell regression on windows
1 parent 5f6ec1f commit 4a562be

2 files changed

Lines changed: 36 additions & 22 deletions

File tree

core/tools/implementations/runTerminalCommand.vitest.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -858,15 +858,22 @@ describe("runTerminalCommandTool.evaluateToolCallPolicy", () => {
858858
expect(result).toBe("allowedWithPermission");
859859
});
860860

861-
it("does not pass login-shell flag to csh-family shells", () => {
862-
const previousShell = process.env.SHELL;
863-
process.env.SHELL = "/bin/tcsh";
864-
try {
865-
const { shell, args } = getShellCommand("pwd");
866-
expect(shell).toBe("/bin/tcsh");
867-
expect(args).toEqual(["-c", "pwd"]);
868-
} finally {
869-
process.env.SHELL = previousShell;
870-
}
871-
});
861+
it.runIf(process.platform !== "win32")(
862+
"does not pass login-shell flag to csh-family shells",
863+
() => {
864+
const previousShell = process.env.SHELL;
865+
process.env.SHELL = "/bin/tcsh";
866+
try {
867+
const { shell, args } = getShellCommand("pwd");
868+
expect(shell).toBe("/bin/tcsh");
869+
expect(args).toEqual(["-c", "pwd"]);
870+
} finally {
871+
if (previousShell === undefined) {
872+
delete process.env.SHELL;
873+
} else {
874+
process.env.SHELL = previousShell;
875+
}
876+
}
877+
},
878+
);
872879
});

extensions/cli/src/tools/runTerminalCommand.test.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,23 @@ describe("runTerminalCommandTool", () => {
124124
});
125125

126126
describe("shell selection", () => {
127-
it("does not pass login-shell flag to csh-family shells", () => {
128-
const previousShell = process.env.SHELL;
129-
process.env.SHELL = "/bin/tcsh";
130-
try {
131-
const { shell, args } = getShellCommand("pwd");
132-
expect(shell).toBe("/bin/tcsh");
133-
expect(args).toEqual(["-c", "pwd"]);
134-
} finally {
135-
process.env.SHELL = previousShell;
136-
}
137-
});
127+
it.runIf(!isWindows)(
128+
"does not pass login-shell flag to csh-family shells",
129+
() => {
130+
const previousShell = process.env.SHELL;
131+
process.env.SHELL = "/bin/tcsh";
132+
try {
133+
const { shell, args } = getShellCommand("pwd");
134+
expect(shell).toBe("/bin/tcsh");
135+
expect(args).toEqual(["-c", "pwd"]);
136+
} finally {
137+
if (previousShell === undefined) {
138+
delete process.env.SHELL;
139+
} else {
140+
process.env.SHELL = previousShell;
141+
}
142+
}
143+
},
144+
);
138145
});
139146
});

0 commit comments

Comments
 (0)