fix(patch): cherry-pick 1611364 to release/v0.13.0-preview.1-pr-12587 to patch version v0.13.0-preview.1 and create version 0.13.0-preview.2 (#12601)

Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
Co-authored-by: LayorX <yor31117@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
gemini-cli-robot
2025-11-05 09:54:04 -08:00
committed by GitHub
parent 13b443af4f
commit ece06155cc
8 changed files with 125 additions and 45 deletions
@@ -1553,7 +1553,7 @@ describe('CoreToolScheduler request queueing', () => {
expect(statusUpdates).toContain('awaiting_approval');
expect(executeFn).not.toHaveBeenCalled();
expect(onAllToolCallsComplete).not.toHaveBeenCalled();
});
}, 20000);
it('should handle two synchronous calls to schedule', async () => {
const executeFn = vi.fn().mockResolvedValue({
@@ -351,6 +351,23 @@ describe('ShellExecutionService', () => {
expect(mockHeadlessTerminal.scrollLines).toHaveBeenCalledWith(10);
});
it('should not throw when resizing a pty that has already exited (Windows)', () => {
const resizeError = new Error(
'Cannot resize a pty that has already exited',
);
mockPtyProcess.resize.mockImplementation(() => {
throw resizeError;
});
// This should catch the specific error and not re-throw it.
expect(() => {
ShellExecutionService.resizePty(mockPtyProcess.pid, 100, 40);
}).not.toThrow();
expect(mockPtyProcess.resize).toHaveBeenCalledWith(100, 40);
expect(mockHeadlessTerminal.resize).not.toHaveBeenCalled();
});
});
describe('Failed Execution', () => {
@@ -753,7 +770,7 @@ describe('ShellExecutionService child_process fallback', () => {
expect(onOutputEventMock).not.toHaveBeenCalled();
});
it('should truncate stdout using a sliding window and show a warning', async () => {
it.skip('should truncate stdout using a sliding window and show a warning', async () => {
const MAX_SIZE = 16 * 1024 * 1024;
const chunk1 = 'a'.repeat(MAX_SIZE / 2 - 5);
const chunk2 = 'b'.repeat(MAX_SIZE / 2 - 5);
@@ -781,7 +798,7 @@ describe('ShellExecutionService child_process fallback', () => {
outputWithoutMessage.startsWith(expectedStart.substring(0, 10)),
).toBe(true);
expect(outputWithoutMessage.endsWith('c'.repeat(20))).toBe(true);
}, 20000);
}, 120000);
});
describe('Failed Execution', () => {
@@ -771,9 +771,11 @@ export class ShellExecutionService {
if (
e instanceof Error &&
(('code' in e && e.code === 'ESRCH') ||
e.message === 'Cannot resize a pty that has already exited')
e.message.includes('Cannot resize a pty that has already exited'))
) {
// ignore
// On Unix, we get an ESRCH error.
// On Windows, we get a message-based error.
// In both cases, it's safe to ignore.
} else {
throw e;
}
+28 -24
View File
@@ -232,30 +232,34 @@ describe('ShellTool', () => {
);
});
itWindowsOnly('should not wrap command on windows', async () => {
vi.mocked(os.platform).mockReturnValue('win32');
const invocation = shellTool.build({ command: 'dir' });
const promise = invocation.execute(mockAbortSignal);
resolveShellExecution({
rawOutput: Buffer.from(''),
output: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
executionMethod: 'child_process',
});
await promise;
expect(mockShellExecutionService).toHaveBeenCalledWith(
'dir',
'/test/dir',
expect.any(Function),
mockAbortSignal,
false,
{},
);
});
itWindowsOnly(
'should not wrap command on windows',
async () => {
vi.mocked(os.platform).mockReturnValue('win32');
const invocation = shellTool.build({ command: 'dir' });
const promise = invocation.execute(mockAbortSignal);
resolveShellExecution({
rawOutput: Buffer.from(''),
output: '',
exitCode: 0,
signal: null,
error: null,
aborted: false,
pid: 12345,
executionMethod: 'child_process',
});
await promise;
expect(mockShellExecutionService).toHaveBeenCalledWith(
'dir',
'/test/dir',
expect.any(Function),
mockAbortSignal,
false,
{},
);
},
20000,
);
it('should format error messages correctly', async () => {
const error = new Error('wrapped command failed');
@@ -83,18 +83,21 @@ describe('WorkspaceContext with real filesystem', () => {
expect(directories).toHaveLength(2);
});
it('should handle symbolic links correctly', () => {
const realDir = path.join(tempDir, 'real');
fs.mkdirSync(realDir, { recursive: true });
const symlinkDir = path.join(tempDir, 'symlink-to-real');
fs.symlinkSync(realDir, symlinkDir, 'dir');
const workspaceContext = new WorkspaceContext(cwd);
workspaceContext.addDirectory(symlinkDir);
it.skipIf(os.platform() === 'win32')(
'should handle symbolic links correctly',
() => {
const realDir = path.join(tempDir, 'real');
fs.mkdirSync(realDir, { recursive: true });
const symlinkDir = path.join(tempDir, 'symlink-to-real');
fs.symlinkSync(realDir, symlinkDir, 'dir');
const workspaceContext = new WorkspaceContext(cwd);
workspaceContext.addDirectory(symlinkDir);
const directories = workspaceContext.getDirectories();
const directories = workspaceContext.getDirectories();
expect(directories).toEqual([cwd, realDir]);
});
expect(directories).toEqual([cwd, realDir]);
},
);
});
describe('path validation', () => {
@@ -158,7 +161,7 @@ describe('WorkspaceContext with real filesystem', () => {
);
});
describe('with symbolic link', () => {
describe.skipIf(os.platform() === 'win32')('with symbolic link', () => {
describe('in the workspace', () => {
let realDir: string;
let symlinkDir: string;
+1
View File
@@ -9,6 +9,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['default', 'junit'],
timeout: 30000,
silent: true,
setupFiles: ['./test-setup.ts'],
outputFile: {