mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-02-01 22:48:03 +00:00
test: add integration test to verify stdout/stderr routing (#17280)
Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
@@ -555,6 +555,48 @@ export class TestRig {
|
||||
return filteredLines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the CLI and returns stdout and stderr separately.
|
||||
* Useful for tests that need to verify correct stream routing.
|
||||
*/
|
||||
runWithStreams(
|
||||
args: string[],
|
||||
options?: { signal?: AbortSignal },
|
||||
): Promise<{ stdout: string; stderr: string; exitCode: number | null }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { command, initialArgs } = this._getCommandAndArgs([
|
||||
'--approval-mode=yolo',
|
||||
]);
|
||||
|
||||
const allArgs = [...initialArgs, ...args];
|
||||
|
||||
const child = spawn(command, allArgs, {
|
||||
cwd: this.testDir!,
|
||||
stdio: 'pipe',
|
||||
env: { ...process.env, GEMINI_CLI_HOME: this.homeDir! },
|
||||
signal: options?.signal,
|
||||
});
|
||||
this._spawnedProcesses.push(child);
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
child.on('error', reject);
|
||||
|
||||
child.stdout!.on('data', (chunk) => {
|
||||
stdout += chunk;
|
||||
});
|
||||
child.stderr!.on('data', (chunk) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
|
||||
child.stdin!.end();
|
||||
child.on('close', (exitCode) => {
|
||||
resolve({ stdout, stderr, exitCode });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(
|
||||
args: string[],
|
||||
options: {
|
||||
|
||||
Reference in New Issue
Block a user