Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(append): restore process.exitCode after each in-process append run (stress gate: leaked exit code failed the file 10/10)
garrytan952826ebe7b1
diff --git a/test/append-file-read.test.ts b/test/append-file-read.test.tsindex 8ea2e01b48..b5d1e5d566 100644--- a/test/append-file-read.test.ts+++ b/test/append-file-read.test.ts@@ -24,11 +24,15 @@ describe('gbrain append --file reads by size', () => {async function append(args: string[]): Promise<{ code: number; stderr: string }> {_resetCliExitVerdictForTests();+ const priorExitCode = process.exitCode;let stderr = '';const write = process.stderr.write.bind(process.stderr);process.stderr.write = ((chunk: string | Uint8Array) => { stderr += String(chunk); return true; }) as typeof process.stderr.write;try { await withEnv({ GBRAIN_HOME: dir, HOME: dir }, () => run(args, ctx)); } finally { process.stderr.write = write; }- return { code: currentExitCode(), stderr };+ const code = currentExitCode();+ _resetCliExitVerdictForTests();+ process.exitCode = priorExitCode ?? 0;+ return { code, stderr };}beforeAll(() => {