mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 06:54:15 -07:00
test(integration): Add "Ctrl + C" to exit integration test (#9272)
This commit is contained in:
@@ -10,6 +10,7 @@ import { join, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { env } from 'node:process';
|
||||
import fs from 'node:fs';
|
||||
import * as pty from '@lydell/node-pty';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -719,4 +720,39 @@ export class TestRig {
|
||||
}
|
||||
return lastApiRequest;
|
||||
}
|
||||
|
||||
runInteractive(...args: string[]): {
|
||||
ptyProcess: pty.IPty;
|
||||
promise: Promise<{ exitCode: number; signal?: number; output: string }>;
|
||||
} {
|
||||
const commandArgs = [this.bundlePath, '--yolo', ...args];
|
||||
|
||||
const ptyProcess = pty.spawn('node', commandArgs, {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
rows: 30,
|
||||
cwd: this.testDir!,
|
||||
env: process.env as { [key: string]: string },
|
||||
});
|
||||
|
||||
let output = '';
|
||||
ptyProcess.onData((data) => {
|
||||
output += data;
|
||||
if (env.KEEP_OUTPUT === 'true' || env.VERBOSE === 'true') {
|
||||
process.stdout.write(data);
|
||||
}
|
||||
});
|
||||
|
||||
const promise = new Promise<{
|
||||
exitCode: number;
|
||||
signal?: number;
|
||||
output: string;
|
||||
}>((resolve) => {
|
||||
ptyProcess.onExit(({ exitCode, signal }) => {
|
||||
resolve({ exitCode, signal, output });
|
||||
});
|
||||
});
|
||||
|
||||
return { ptyProcess, promise };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user