mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix: use && for windows background keep-alive ping and add test
This commit is contained in:
@@ -833,6 +833,41 @@ describe('ShellTool', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Windows background execution', () => {
|
describe('Windows background execution', () => {
|
||||||
|
it('should append keep-alive ping with && on Windows for background tasks', async () => {
|
||||||
|
vi.mocked(os.platform).mockReturnValue('win32');
|
||||||
|
const mockAbortSignal = new AbortController().signal;
|
||||||
|
|
||||||
|
const invocation = shellTool.build({
|
||||||
|
command: 'npm start',
|
||||||
|
is_background: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const promise = invocation.execute(mockAbortSignal);
|
||||||
|
|
||||||
|
// Simulate immediate success (process started)
|
||||||
|
resolveExecutionPromise({
|
||||||
|
rawOutput: Buffer.from(''),
|
||||||
|
output: '',
|
||||||
|
exitCode: 0,
|
||||||
|
signal: null,
|
||||||
|
error: null,
|
||||||
|
aborted: false,
|
||||||
|
pid: 12345,
|
||||||
|
executionMethod: 'child_process',
|
||||||
|
});
|
||||||
|
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
expect(mockShellExecutionService).toHaveBeenCalledWith(
|
||||||
|
expect.stringContaining('npm start && ping -n 86400 127.0.0.1 >nul'),
|
||||||
|
expect.any(String),
|
||||||
|
expect.any(Function),
|
||||||
|
expect.any(AbortSignal),
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should detect immediate failure in Windows background task', async () => {
|
it('should detect immediate failure in Windows background task', async () => {
|
||||||
vi.mocked(os.platform).mockReturnValue('win32');
|
vi.mocked(os.platform).mockReturnValue('win32');
|
||||||
const mockAbortSignal = new AbortController().signal;
|
const mockAbortSignal = new AbortController().signal;
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
|||||||
while (cmd.endsWith('&')) {
|
while (cmd.endsWith('&')) {
|
||||||
cmd = cmd.slice(0, -1).trim();
|
cmd = cmd.slice(0, -1).trim();
|
||||||
}
|
}
|
||||||
finalCommand = cmd + ' & ping -n 86400 127.0.0.1 >nul';
|
finalCommand = cmd + ' && ping -n 86400 127.0.0.1 >nul';
|
||||||
}
|
}
|
||||||
|
|
||||||
// pgrep is not available on Windows, so we can't get background PIDs
|
// pgrep is not available on Windows, so we can't get background PIDs
|
||||||
|
|||||||
Reference in New Issue
Block a user