Skip to content

Commit 36d6652

Browse files
committed
test: stabilize Node 22 timeout scenarios
1 parent caad175 commit 36d6652

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

tests/fixtures/stop-gate-with-timeout.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ const dataRoot = process.env.PLUGIN_DATA;
88
if (!dataRoot) throw new Error('PLUGIN_DATA required');
99
const discoveryCode = process.env.FAKE_GATE_DISCOVERY_ERROR;
1010
const discoverZCode = discoveryCode ? async () => { throw Object.assign(new Error('fixture discovery failure'), { code: discoveryCode }); } : undefined;
11-
// Windows child startup can consume most of a 100 ms budget under CI. Keep
12-
// the deliberately suppressed completion as the timeout trigger while leaving
13-
// enough time for the fake protocol process to create its session.
14-
const timeoutMs = process.platform === 'win32' ? 2_000 : 100;
11+
const timeoutMs = 2_000;
1512
process.stdout.write(JSON.stringify(await runStopReviewGate(input, { dataRoot, env: process.env, timeoutMs, ...(discoverZCode ? { discoverZCode } : {}) })));

tests/hooks.test.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,11 @@ test('Stop gate suppresses continuation/nested runs, fails open when setup is no
351351
const stop = stopFields(base);
352352
const script = name === 'timeout' ? join(root, 'tests/fixtures/stop-gate-with-timeout.mjs') : 'stop-review-gate-hook.mjs';
353353
const result = await runHook(script, { ...stop, hook_event_name: 'Stop', stop_hook_active: false, last_assistant_message: 'done' }, { ...env, ZCODE_PATH: fakeZCode, FAKE_ZCODE_RECORD: record, FAKE_ZCODE_GATE_RESULT: fake, ...extra }, { absolute: name === 'timeout' });
354+
const calls = ['failure', 'read-failure', 'timeout'].includes(name) ? (await readFile(record, 'utf8')).trim().split('\n').filter(Boolean).map((line) => JSON.parse(line)) : [];
355+
if (name === 'timeout') assert.ok(calls.some((call) => call.method === 'session/send'), 'timeout must reach the intended completion wait');
354356
assert.equal(result.code, 0); if (expected.decision) assert.equal(result.json.decision, expected.decision); else assert.deepEqual(result.json, expected);
355357
if (expected.reason) assert.equal(result.json.reason, expected.reason); if (result.json.reason) assert.ok(result.json.reason.length <= 1000);
356358
if (['failure', 'read-failure', 'timeout'].includes(name)) {
357-
const calls = (await readFile(record, 'utf8')).trim().split('\n').filter(Boolean).map((line) => JSON.parse(line));
358359
assert.ok(calls.some((call) => call.method === 'session/stop'), `${name} must stop its created review session`);
359360
}
360361
});

tests/zcode-client.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ test('session/create rejects unsafe or amplified session identifiers at the ZCod
300300
});
301301

302302
test('disconnect diagnostics retain only a bounded redacted stderr tail', async () => {
303-
await withClient(async (client) => { await client.createSession({ workspace: '/repo' }); await assert.rejects(client.listSessions(), (error) => error.code === 'ZCODE_DISCONNECTED' && error.details.stderrTail.length <= 8192 && !error.details.stderrTail.includes('super-secret') && error.details.stderrTail.includes('[REDACTED]')); }, { FAKE_ZCODE_STDERR_BYTES: '20000', FAKE_ZCODE_STDERR_TEXT: ' token=super-secret ', FAKE_ZCODE_DISCONNECT: 'session/list' });
303+
await withClient(async (client) => { await client.createSession({ workspace: '/repo' }); await assert.rejects(client.listSessions(), (error) => error.code === 'ZCODE_DISCONNECTED' && error.details.stderrTail.length <= 8192 && !error.details.stderrTail.includes('super-secret') && error.details.stderrTail.includes('[REDACTED]')); }, { FAKE_ZCODE_STDERR_BYTES: '20000', FAKE_ZCODE_STDERR_TEXT: ' token=super-secret ', FAKE_ZCODE_DISCONNECT: 'session/list' }, { requestTimeoutMs: 2_000 });
304304
});
305305

306306
test('managed broker clients require an explicit stable owner credential', async () => {

0 commit comments

Comments
 (0)