test: fix hook integration test flakiness on Windows CI

- Increase default timeout for TestRig.run and TestRig.runCommand to 10 minutes on Windows CI to handle slow environments.
- Replace inline 'node -e' hook commands with script files to avoid brittle quoting and escaping issues on Windows shells.
- Add 'TestRig.createScript' helper to simplify script creation in tests.
- Fix path escaping for hook output files in 'hooks-agent-flow.test.ts' using JSON.stringify.
- Ensure 'TestRig.setup' is called before performing file operations in tests.
This commit is contained in:
Taylor Mullen
2026-02-09 11:36:50 -08:00
parent 02da5ebbc1
commit 9631dc8abf
3 changed files with 229 additions and 62 deletions
+15 -2
View File
@@ -438,6 +438,17 @@ export class TestRig {
return filePath;
}
createScript(fileName: string, content: string) {
if (!this.testDir) {
throw new Error(
'TestRig.setup must be called before creating files or scripts',
);
}
const scriptPath = join(this.testDir, fileName);
writeFileSync(scriptPath, content);
return scriptPath;
}
mkdir(dir: string) {
mkdirSync(join(this.testDir!, dir), { recursive: true });
}
@@ -572,7 +583,8 @@ export class TestRig {
}
});
const timeout = options.timeout ?? 300000;
const isWinCI = os.platform() === 'win32' && process.env['CI'] === 'true';
const timeout = options.timeout ?? (isWinCI ? 600000 : 300000); // 10 mins on Win CI, 5 mins otherwise
const promise = new Promise<string>((resolve, reject) => {
const timer = setTimeout(() => {
child.kill('SIGKILL');
@@ -743,7 +755,8 @@ export class TestRig {
}
});
const timeout = options.timeout ?? 300000;
const isWinCI = os.platform() === 'win32' && process.env['CI'] === 'true';
const timeout = options.timeout ?? (isWinCI ? 600000 : 300000); // 10 mins on Win CI, 5 mins otherwise
const promise = new Promise<string>((resolve, reject) => {
const timer = setTimeout(() => {
child.kill('SIGKILL');