summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/shell.test.ts
diff options
context:
space:
mode:
authorGal Zahavi <[email protected]>2025-08-19 16:03:51 -0700
committerGitHub <[email protected]>2025-08-19 23:03:51 +0000
commitf1575f6d8de2f4efa0805a2d11a4a421a1a8228f (patch)
tree8977235b9a42983de3e76189f25ff055e9d28a83 /packages/core/src/tools/shell.test.ts
parent0cc2a1e7ef904294fff982a4d75bf098b5b262f7 (diff)
feat(core): refactor shell execution to use node-pty (#6491)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/core/src/tools/shell.test.ts')
-rw-r--r--packages/core/src/tools/shell.test.ts32
1 files changed, 15 insertions, 17 deletions
diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts
index c0b409fa..79354cf8 100644
--- a/packages/core/src/tools/shell.test.ts
+++ b/packages/core/src/tools/shell.test.ts
@@ -56,6 +56,7 @@ describe('ShellTool', () => {
getSummarizeToolOutputConfig: vi.fn().mockReturnValue(undefined),
getWorkspaceContext: () => createMockWorkspaceContext('.'),
getGeminiClient: vi.fn(),
+ getShouldUseNodePtyShell: vi.fn().mockReturnValue(false),
} as unknown as Config;
shellTool = new ShellTool(mockConfig);
@@ -123,13 +124,12 @@ describe('ShellTool', () => {
const fullResult: ShellExecutionResult = {
rawOutput: Buffer.from(result.output || ''),
output: 'Success',
- stdout: 'Success',
- stderr: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
...result,
};
resolveExecutionPromise(fullResult);
@@ -152,6 +152,9 @@ describe('ShellTool', () => {
expect.any(String),
expect.any(Function),
mockAbortSignal,
+ false,
+ undefined,
+ undefined,
);
expect(result.llmContent).toContain('Background PIDs: 54322');
expect(vi.mocked(fs.unlinkSync)).toHaveBeenCalledWith(tmpFile);
@@ -164,13 +167,12 @@ describe('ShellTool', () => {
resolveShellExecution({
rawOutput: Buffer.from(''),
output: '',
- stdout: '',
- stderr: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
});
await promise;
expect(mockShellExecutionService).toHaveBeenCalledWith(
@@ -178,6 +180,9 @@ describe('ShellTool', () => {
expect.any(String),
expect.any(Function),
mockAbortSignal,
+ false,
+ undefined,
+ undefined,
);
});
@@ -189,16 +194,14 @@ describe('ShellTool', () => {
error,
exitCode: 1,
output: 'err',
- stderr: 'err',
rawOutput: Buffer.from('err'),
- stdout: '',
signal: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
});
const result = await promise;
- // The final llmContent should contain the user's command, not the wrapper
expect(result.llmContent).toContain('Error: wrapped command failed');
expect(result.llmContent).not.toContain('pgrep');
});
@@ -231,13 +234,12 @@ describe('ShellTool', () => {
resolveExecutionPromise({
output: 'long output',
rawOutput: Buffer.from('long output'),
- stdout: 'long output',
- stderr: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
});
const result = await promise;
@@ -283,7 +285,6 @@ describe('ShellTool', () => {
// First chunk, should be throttled.
mockShellOutputCallback({
type: 'data',
- stream: 'stdout',
chunk: 'hello ',
});
expect(updateOutputMock).not.toHaveBeenCalled();
@@ -294,24 +295,22 @@ describe('ShellTool', () => {
// Send a second chunk. THIS event triggers the update with the CUMULATIVE content.
mockShellOutputCallback({
type: 'data',
- stream: 'stderr',
- chunk: 'world',
+ chunk: 'hello world',
});
// It should have been called once now with the combined output.
expect(updateOutputMock).toHaveBeenCalledOnce();
- expect(updateOutputMock).toHaveBeenCalledWith('hello \nworld');
+ expect(updateOutputMock).toHaveBeenCalledWith('hello world');
resolveExecutionPromise({
rawOutput: Buffer.from(''),
output: '',
- stdout: '',
- stderr: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
});
await promise;
});
@@ -350,13 +349,12 @@ describe('ShellTool', () => {
resolveExecutionPromise({
rawOutput: Buffer.from(''),
output: '',
- stdout: '',
- stderr: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
+ executionMethod: 'child_process',
});
await promise;
});