mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(temporary): Don't run ctrl+c exit test on windows (#9785)
This commit is contained in:
committed by
GitHub
parent
18e5113754
commit
8bf8707668
@@ -8,47 +8,52 @@ import { describe, it, expect } from 'vitest';
|
|||||||
import { TestRig } from './test-helper.js';
|
import { TestRig } from './test-helper.js';
|
||||||
|
|
||||||
describe('Ctrl+C exit', () => {
|
describe('Ctrl+C exit', () => {
|
||||||
it('should exit gracefully on second Ctrl+C', async () => {
|
// (#9782) Temporarily disabling on windows because it is failing on main and every
|
||||||
const rig = new TestRig();
|
// PR, which is potentially hiding other failures
|
||||||
await rig.setup('should exit gracefully on second Ctrl+C');
|
it.skipIf(process.platform === 'win32')(
|
||||||
|
'should exit gracefully on second Ctrl+C',
|
||||||
|
async () => {
|
||||||
|
const rig = new TestRig();
|
||||||
|
await rig.setup('should exit gracefully on second Ctrl+C');
|
||||||
|
|
||||||
const { ptyProcess, promise } = rig.runInteractive();
|
const { ptyProcess, promise } = rig.runInteractive();
|
||||||
|
|
||||||
let output = '';
|
let output = '';
|
||||||
ptyProcess.onData((data) => {
|
ptyProcess.onData((data) => {
|
||||||
output += data;
|
output += data;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait for the app to be ready by looking for the initial prompt indicator
|
// Wait for the app to be ready by looking for the initial prompt indicator
|
||||||
await rig.poll(() => output.includes('▶'), 5000, 100);
|
await rig.poll(() => output.includes('▶'), 5000, 100);
|
||||||
|
|
||||||
// Send first Ctrl+C
|
// Send first Ctrl+C
|
||||||
ptyProcess.write('\x03');
|
ptyProcess.write('\x03');
|
||||||
|
|
||||||
// Wait for the exit prompt
|
// Wait for the exit prompt
|
||||||
await rig.poll(
|
await rig.poll(
|
||||||
() => output.includes('Press Ctrl+C again to exit'),
|
() => output.includes('Press Ctrl+C again to exit'),
|
||||||
1500,
|
1500,
|
||||||
50,
|
50,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send second Ctrl+C
|
// Send second Ctrl+C
|
||||||
ptyProcess.write('\x03');
|
ptyProcess.write('\x03');
|
||||||
|
|
||||||
const result = await promise;
|
const result = await promise;
|
||||||
|
|
||||||
// Expect a graceful exit (code 0)
|
// Expect a graceful exit (code 0)
|
||||||
expect(
|
expect(
|
||||||
result.exitCode,
|
result.exitCode,
|
||||||
`Process exited with code ${result.exitCode}. Output: ${result.output}`,
|
`Process exited with code ${result.exitCode}. Output: ${result.output}`,
|
||||||
).toBe(0);
|
).toBe(0);
|
||||||
|
|
||||||
// Check that the quitting message is displayed
|
// Check that the quitting message is displayed
|
||||||
const quittingMessage = 'Agent powering down. Goodbye!';
|
const quittingMessage = 'Agent powering down. Goodbye!';
|
||||||
// The regex below is intentionally matching the ESC control character (\x1b)
|
// The regex below is intentionally matching the ESC control character (\x1b)
|
||||||
// to strip ANSI color codes from the terminal output.
|
// to strip ANSI color codes from the terminal output.
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
const cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
const cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
||||||
expect(cleanOutput).toContain(quittingMessage);
|
expect(cleanOutput).toContain(quittingMessage);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user