refactor(test): finish createHookScript refactor and cleanup

- Ensure all hook tests use rig.createHookScript for consistent path normalization.
- Remove unused writeFileSync and readFileSync imports from integration tests.
- Fix assertions in 'input override' test to match new .cjs extension and be more robust.
This commit is contained in:
Abhi
2026-02-06 13:19:31 -05:00
parent e1d8cc78d7
commit e2b96018bd
3 changed files with 151 additions and 155 deletions

View File

@@ -387,6 +387,19 @@ export class TestRig {
this._createSettingsFile(options.settings);
}
/**
* Creates a hook script file and returns a normalized path suitable for cross-platform execution.
*/
createHookScript(fileName: string, content: string): string {
if (!this.testDir) {
throw new Error('TestRig must be setup before calling createHookScript');
}
const scriptPath = join(this.testDir, fileName);
writeFileSync(scriptPath, content);
// Return a path normalized for use in shell commands across platforms.
return scriptPath.replace(/\\/g, '/');
}
private _createSettingsFile(overrideSettings?: Record<string, unknown>) {
const projectGeminiDir = join(this.testDir!, GEMINI_DIR);
mkdirSync(projectGeminiDir, { recursive: true });