fix(clean): every change rechecks the verified folder and the measured file; full writes; EPIPE ends output quietly

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-01 01:26:23 +00:00
1 parent 32f43717fe
commit 1bca95029f
3 files changed
+58 -16

No files matched your search

+11
View File
@@ -453,6 +453,17 @@ describe('gstack-clean', () => {
}
});
test('a reader that closes early does not turn a finished run into an internal error', () => {
const f = fixture();
for (let i = 0; i < 300; i++) put(path.join(f.gs, 'tmp', 'codex-err-' + String(i).padStart(6, '0')), 'x', 30 * DAY);
const env: Record<string, string> = { PATH: quietPsPath(f), HOME: f.home, GSTACK_HOME: f.state };
const cmd = [process.execPath, ...bunIsolationArgs(), BIN, '--apply', '--json'].map(a => "'" + a.replace(/'/g, "'\\''") + "'").join(' ') + " 2>'" + path.join(f.root, 'err.txt') + "' | head -c 1 >/dev/null";
const r = spawnSync('bash', ['-c', cmd], { cwd: f.repo, env, encoding: 'utf8', timeout: 30_000 });
expect(r.status).toBe(0);
expect(fs.readFileSync(path.join(f.root, 'err.txt'), 'utf8')).not.toContain('GSTACK_CLEAN_INTERNAL');
expect(fs.readdirSync(path.join(f.gs, 'tmp')).filter(n => n.startsWith('codex-'))).toEqual([]);
});
test('--json reaches a pipe whole with hundreds of actions', () => {
const f = fixture();
for (let i = 0; i < 300; i++) put(path.join(f.gs, 'tmp', 'codex-err-' + String(i).padStart(6, '0')), 'x', 30 * DAY);