test: robust fixes for windows hook flakiness

- Enforce 'sequential: true' for all hook tests to prevent telemetry leaks and race conditions.
- Normalize all path assertions in hooks-system.test.ts using a new 'normalizePath' helper to handle Windows backslashes consistently.
- Update 'createScript' in test-rig to return normalized paths.
- Ensure 'PATH' is explicitly passed to node-pty spawn options to prevent 'posix_spawnp' errors in some environments.
- Clean up manual path replacements in tests in favor of the centralized helper.

Part of https://github.com/google-gemini/gemini-cli/pull/18665
This commit is contained in:
Taylor Mullen
2026-02-09 22:41:15 -08:00
parent 519bf324b0
commit bd7904a9f7
3 changed files with 99 additions and 53 deletions
+14 -1
View File
@@ -60,6 +60,14 @@ export function sanitizeTestName(name: string) {
.replace(/-+/g, '-');
}
/**
* Normalizes a path for use in command-line arguments.
* On Windows, this converts backslashes to forward slashes.
*/
export function normalizePath(p: string): string {
return p.replace(/\\/g, '/');
}
// Helper to create detailed error messages
export function createToolCallErrorMessage(
expectedTools: string | string[],
@@ -446,7 +454,7 @@ export class TestRig {
}
const scriptPath = join(this.testDir, fileName);
writeFileSync(scriptPath, content);
return scriptPath;
return normalizePath(scriptPath);
}
mkdir(dir: string) {
@@ -1295,6 +1303,11 @@ export class TestRig {
const envVars = this._getCleanEnv(options?.env);
// Ensure PATH is included for pty
if (!envVars['PATH'] && process.env['PATH']) {
envVars['PATH'] = process.env['PATH'];
}
const ptyOptions: pty.IPtyForkOptions = {
name: 'xterm-color',
cols: 80,