mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-17 13:30:53 -07:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user