mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-29 21:23:29 -07:00
test: fix windows environment and cleanup issues
- Ensure 'SystemRoot', 'COMSPEC', 'windir', and 'PATHEXT' are passed to node-pty on Windows to prevent 'posix_spawnp' failures. - Clean up test directories in 'TestRig.setup' to ensure a fresh state for retries and prevent telemetry log accumulation (fixing the 1, 2, 3 failure pattern). - Fix path normalization in 'Hook Disabling' test to ensure disabled hooks are correctly matched on Windows. Part of https://github.com/google-gemini/gemini-cli/pull/18665
This commit is contained in:
@@ -1831,7 +1831,7 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho
|
||||
settings: {
|
||||
hooksConfig: {
|
||||
enabled: true,
|
||||
disabled: [`node "${disabledPath}"`], // Disable the second hook
|
||||
disabled: [normalizePath(`node "${disabledPath}"`)], // Disable the second hook
|
||||
},
|
||||
hooks: {
|
||||
BeforeTool: [
|
||||
|
||||
@@ -367,6 +367,15 @@ export class TestRig {
|
||||
env['INTEGRATION_TEST_FILE_DIR'] || join(os.tmpdir(), 'gemini-cli-tests');
|
||||
this.testDir = join(testFileDir, sanitizedName);
|
||||
this.homeDir = join(testFileDir, sanitizedName + '-home');
|
||||
|
||||
// Clean up existing directories from previous runs (e.g. retries)
|
||||
if (fs.existsSync(this.testDir)) {
|
||||
fs.rmSync(this.testDir, { recursive: true, force: true });
|
||||
}
|
||||
if (fs.existsSync(this.homeDir)) {
|
||||
fs.rmSync(this.homeDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
mkdirSync(this.testDir, { recursive: true });
|
||||
mkdirSync(this.homeDir, { recursive: true });
|
||||
if (options.fakeResponsesPath) {
|
||||
@@ -1308,6 +1317,15 @@ export class TestRig {
|
||||
envVars['PATH'] = process.env['PATH'];
|
||||
}
|
||||
|
||||
// Add critical Windows environment variables if missing
|
||||
if (process.platform === 'win32') {
|
||||
['SystemRoot', 'COMSPEC', 'windir', 'PATHEXT'].forEach((key) => {
|
||||
if (!envVars[key] && process.env[key]) {
|
||||
envVars[key] = process.env[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const ptyOptions: pty.IPtyForkOptions = {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
|
||||
Reference in New Issue
Block a user