-
Notifications
You must be signed in to change notification settings - Fork 164
fix: use VS Code default shell for command execution instead of /bin/sh #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // npx vitest run integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts | ||
|
|
||
| const mockPid = 12345 | ||
| const mockGetShell = vitest.fn(() => "/bin/bash") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the Vitest docs, |
||
|
|
||
| vitest.mock("execa", () => { | ||
| const mockKill = vitest.fn() | ||
|
|
@@ -21,6 +22,10 @@ vitest.mock("ps-tree", () => ({ | |
| default: vitest.fn((_: number, cb: any) => cb(null, [])), | ||
| })) | ||
|
|
||
| vitest.mock("../../../utils/shell", () => ({ | ||
| getShell: () => mockGetShell(), | ||
| })) | ||
|
|
||
| import { execa } from "execa" | ||
| import { ExecaTerminalProcess } from "../ExecaTerminalProcess" | ||
| import { BaseTerminal } from "../BaseTerminal" | ||
|
|
@@ -63,7 +68,7 @@ describe("ExecaTerminalProcess", () => { | |
| const execaMock = vitest.mocked(execa) | ||
| expect(execaMock).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| shell: true, | ||
| shell: "/bin/bash", | ||
| cwd: "/test/cwd", | ||
| all: true, | ||
| env: expect.objectContaining({ | ||
|
|
@@ -105,13 +110,14 @@ describe("ExecaTerminalProcess", () => { | |
| ) | ||
| }) | ||
|
|
||
| it("should fall back to shell=true when execaShellPath is undefined", async () => { | ||
| it("should fall back to getShell() when execaShellPath is undefined", async () => { | ||
| BaseTerminal.setExecaShellPath(undefined) | ||
| mockGetShell.mockReturnValue("/usr/bin/zsh") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "should use execaShellPath when set" test (above) sets |
||
| await terminalProcess.run("echo test") | ||
| const execaMock = vitest.mocked(execa) | ||
| expect(execaMock).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| shell: true, | ||
| shell: "/usr/bin/zsh", | ||
| }), | ||
| ) | ||
| }) | ||
|
Comment on lines
+113
to
123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix test isolation issue to prevent flakiness. Using 🔧 Proposed fix using mockReturnValueOnce it("should fall back to getShell() when execaShellPath is undefined", async () => {
BaseTerminal.setExecaShellPath(undefined)
- mockGetShell.mockReturnValue("/usr/bin/zsh")
+ mockGetShell.mockReturnValueOnce("/usr/bin/zsh")
await terminalProcess.run("echo test")
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(🤖 Prompt for AI Agents |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this line picked up an extra leading tab — it's indented one level deeper than its siblings (
cwd,all,stdin,env), curious how lint didn't flag this.