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:
Taylor Mullen
2026-02-09 23:18:02 -08:00
parent 3643c882ee
commit f54fe58d06
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -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: [
+18
View File
@@ -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,