mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix(cli) - Add logging for shell errors (#7007)
Co-authored-by: Shi Shu <shii@google.com> Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@ import { EOL } from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import * as crypto from 'node:crypto';
|
||||
import * as summarizer from '../utils/summarizer.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import { ToolConfirmationOutcome } from './tools.js';
|
||||
import { OUTPUT_UPDATE_INTERVAL_MS } from './shell.js';
|
||||
import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.js';
|
||||
@@ -207,6 +208,22 @@ describe('ShellTool', () => {
|
||||
expect(result.llmContent).not.toContain('pgrep');
|
||||
});
|
||||
|
||||
it('should return a SHELL_EXECUTE_ERROR for a command failure', async () => {
|
||||
const error = new Error('command failed');
|
||||
const invocation = shellTool.build({ command: 'user-command' });
|
||||
const promise = invocation.execute(mockAbortSignal);
|
||||
resolveShellExecution({
|
||||
error,
|
||||
exitCode: 1,
|
||||
});
|
||||
|
||||
const result = await promise;
|
||||
|
||||
expect(result.error).toBeDefined();
|
||||
expect(result.error?.type).toBe(ToolErrorType.SHELL_EXECUTE_ERROR);
|
||||
expect(result.error?.message).toBe('command failed');
|
||||
});
|
||||
|
||||
it('should throw an error for invalid parameters', () => {
|
||||
expect(() => shellTool.build({ command: '' })).toThrow(
|
||||
'Command cannot be empty.',
|
||||
|
||||
Reference in New Issue
Block a user