fix(tests): the post-compact hook test takes its child timeout from the shared timing helper
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cd3225b630
commit
c9248bbb52
4 changed files with 40 additions and 5 deletions
|
|
@ -12,9 +12,10 @@
|
|||
|
||||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { fastestWithin } from '../helpers/timing.mjs';
|
||||
import * as timing from '../helpers/timing.mjs';
|
||||
import { HOOK_TIMEOUT_MS, runHookWithEnv } from '../helpers/hook-helper.mjs';
|
||||
|
|
@ -81,3 +82,24 @@ test('red proof control run (703d87e1): the timeout leaves headroom over a slow
|
|||
assert.ok(c.hangMs >= c.timeoutMs + 30000, `the hang outlasts the timeout by 30 s: ${seen}`);
|
||||
assert.ok(c.hangMs < 2 ** 31 - 1, `the hang fits a real timer (below 2^31-1 ms): ${seen}`);
|
||||
});
|
||||
|
||||
// The post-compact hook test (tests/hooks/post-compact-flush.test.mjs) ran its
|
||||
// hook child with a fixed 5 s limit and was killed under full-suite load
|
||||
// (decision 44, the same class as 703d87e1). Its limit now comes from
|
||||
// tests/helpers/timing.mjs (HOOK_CHILD_TIMEOUT_MS), shared with the hook
|
||||
// helper. The fallback 5000 is the record of the limit before decision 44,
|
||||
// taken only when the export is absent.
|
||||
test('post-compact-flush (decision 44): its child timeout comes from tests/helpers/timing.mjs', () => {
|
||||
const hookTest = readFileSync(
|
||||
join(dirname(fileURLToPath(import.meta.url)), '..', 'hooks', 'post-compact-flush.test.mjs'),
|
||||
'utf8',
|
||||
);
|
||||
assert.ok(hookTest.includes("'../helpers/timing.mjs'"), 'the hook test imports from ../helpers/timing.mjs');
|
||||
assert.ok(hookTest.includes('timeout: HOOK_CHILD_TIMEOUT_MS'), 'the hook test uses timeout: HOOK_CHILD_TIMEOUT_MS');
|
||||
assert.doesNotMatch(hookTest, /\b5_?000\b/, 'the hook test holds no 5000 literal');
|
||||
const limit = timing.HOOK_CHILD_TIMEOUT_MS ?? 5000;
|
||||
assert.ok(limit > 5000, `the shared child timeout is above the old 5 s: ${limit}`);
|
||||
assert.equal(HOOK_TIMEOUT_MS, timing.HOOK_CHILD_TIMEOUT_MS, 'the hook helper and the hook test share one number');
|
||||
assert.ok(hookTest.includes('child.exitCode ?? 1'), 'a killed child reads as non-zero');
|
||||
assert.ok(!hookTest.includes('?? 0'), 'no killed child reads as exit 0');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue