mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Make shell output consistent. (#4469)
This commit is contained in:
@@ -10,6 +10,7 @@ import { useShellCommandProcessor } from './shellCommandProcessor';
|
||||
import { Config, GeminiClient } from '@google/gemini-cli-core';
|
||||
import * as fs from 'fs';
|
||||
import EventEmitter from 'events';
|
||||
import { ToolCallStatus } from '../types';
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('child_process');
|
||||
@@ -104,8 +105,15 @@ describe('useShellCommandProcessor', () => {
|
||||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'info',
|
||||
text: 'file1.txt\nfile2.txt',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'ls -l',
|
||||
status: ToolCallStatus.Success,
|
||||
resultDisplay: 'file1.txt\nfile2.txt',
|
||||
}),
|
||||
],
|
||||
});
|
||||
expect(geminiClientMock.addHistory).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
@@ -140,8 +148,16 @@ describe('useShellCommandProcessor', () => {
|
||||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'info',
|
||||
text: '[Command produced binary output, which is not shown.]',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'cat myimage.png',
|
||||
status: ToolCallStatus.Success,
|
||||
resultDisplay:
|
||||
'[Command produced binary output, which is not shown.]',
|
||||
}),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -172,8 +188,15 @@ describe('useShellCommandProcessor', () => {
|
||||
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
expect(addItemToHistoryMock.mock.calls[1][0]).toEqual({
|
||||
type: 'error',
|
||||
text: 'Command exited with code 127.\ncommand not found',
|
||||
type: 'tool_group',
|
||||
tools: [
|
||||
expect.objectContaining({
|
||||
name: 'Shell Command',
|
||||
description: 'a-bad-command',
|
||||
status: ToolCallStatus.Error,
|
||||
resultDisplay: 'Command exited with code 127.\ncommand not found',
|
||||
}),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user