diff options
| author | Tommaso Sciortino <[email protected]> | 2025-07-25 12:05:21 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-25 19:05:21 +0000 |
| commit | f0e3e6ee8a0a3efaf25cb10f4f8df61c5a94c34e (patch) | |
| tree | 225e4de83d5ef96a0f5af42a3b6077cd9afce3e4 /packages/core/src | |
| parent | 1b8ba5ca6bf739e4100a1d313721988f953acb49 (diff) | |
Make shell.test.ts windows compatible (#4858)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/tools/shell.test.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts index 0dff776f..22ae9a0b 100644 --- a/packages/core/src/tools/shell.test.ts +++ b/packages/core/src/tools/shell.test.ts @@ -9,6 +9,7 @@ import { ShellTool } from './shell.js'; import { Config } from '../config/config.js'; import * as summarizer from '../utils/summarizer.js'; import { GeminiClient } from '../core/client.js'; +import os from 'os'; describe('ShellTool', () => { it('should allow a command if no restrictions are provided', async () => { @@ -424,11 +425,11 @@ describe('ShellTool Bug Reproduction', () => { const abortSignal = new AbortController().signal; const result = await shellTool.execute( - { command: 'echo "hello"' }, + { command: 'echo hello' }, abortSignal, ); - expect(result.returnDisplay).toBe('hello\n'); + expect(result.returnDisplay).toBe('hello' + os.EOL); expect(result.llmContent).toBe('summarized output'); expect(summarizeSpy).toHaveBeenCalled(); }); @@ -450,11 +451,11 @@ describe('ShellTool Bug Reproduction', () => { const abortSignal = new AbortController().signal; const result = await shellTool.execute( - { command: 'echo "hello"' }, + { command: 'echo hello' }, abortSignal, ); - expect(result.returnDisplay).toBe('hello\n'); + expect(result.returnDisplay).toBe('hello' + os.EOL); expect(result.llmContent).not.toBe('summarized output'); expect(summarizeSpy).not.toHaveBeenCalled(); }); @@ -477,7 +478,7 @@ describe('ShellTool Bug Reproduction', () => { .mockResolvedValue('summarized output'); const abortSignal = new AbortController().signal; - await shellTool.execute({ command: 'echo "hello"' }, abortSignal); + await shellTool.execute({ command: 'echo hello' }, abortSignal); expect(summarizeSpy).toHaveBeenCalledWith( expect.any(String), @@ -505,7 +506,7 @@ describe('ShellTool Bug Reproduction', () => { .mockResolvedValue('summarized output'); const abortSignal = new AbortController().signal; - await shellTool.execute({ command: 'echo "hello"' }, abortSignal); + await shellTool.execute({ command: 'echo hello' }, abortSignal); expect(summarizeSpy).toHaveBeenCalledWith( expect.any(String), @@ -527,11 +528,10 @@ describe('ShellTool Bug Reproduction', () => { shellTool = new ShellTool(config); const abortSignal = new AbortController().signal; - const result = await shellTool.execute( - { command: 'echo "$GEMINI_CLI"' }, - abortSignal, - ); + const command = + os.platform() === 'win32' ? 'echo %GEMINI_CLI%' : 'echo $GEMINI_CLI'; + const result = await shellTool.execute({ command }, abortSignal); - expect(result.returnDisplay).toBe('1\n'); + expect(result.returnDisplay).toBe('1' + os.EOL); }); }); |
