mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix: handle windows background execution errors and add tests
This commit is contained in:
@@ -831,4 +831,33 @@ describe('ShellTool', () => {
|
||||
expect(shellTool.description).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Windows background execution', () => {
|
||||
it('should detect immediate failure in Windows background task', async () => {
|
||||
vi.mocked(os.platform).mockReturnValue('win32');
|
||||
const mockAbortSignal = new AbortController().signal;
|
||||
|
||||
const invocation = shellTool.build({
|
||||
command: 'invalid_command',
|
||||
is_background: true,
|
||||
});
|
||||
|
||||
const promise = invocation.execute(mockAbortSignal);
|
||||
|
||||
// Wait a tick to ensure mockShellOutputCallback is assigned
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
if (mockShellOutputCallback) {
|
||||
mockShellOutputCallback({
|
||||
type: 'data',
|
||||
chunk:
|
||||
"'invalid_command' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n",
|
||||
});
|
||||
}
|
||||
|
||||
const result = await promise;
|
||||
expect(result.error).toBeDefined();
|
||||
expect(result.llmContent).toContain('Command failed to start');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user