test(#4528): migrate final seam-dispatch batch and retire the timeout-literal allowlist (#4684)

Batch 17 of 17 — the terminal batch — in the ad hoc timeout literal
migration (epic #4445). Replaces every bare numeric timeout/timeoutMs
object-literal property in tests/cjs-command-router-adapter.test.cjs,
tests/dispatcher.test.cjs, tests/run-tests-temp-root.test.cjs, and
tests/shell-command-projection-dispatch.test.cjs with a named constant,
per eslint-rules/no-adhoc-timeout-literal.cjs. No src/bin file touched,
no numeric value changed anywhere.

Eslint ground truth (9 sites) matches the issue's own stated count
exactly for the first time in this epic — no drift to disclose.

Reuses PROBE_TIMEOUT_MS (1 site) and QUICK_SPAWN_TIMEOUT_MS (1 site).
Adds four file-local constants for shapes with no existing match:
RUN_TESTS_ISOLATED_PROBE_TIMEOUT_MS and RUN_TESTS_HARNESS_SPAWN_TIMEOUT_MS
(run-tests-temp-root.test.cjs, distinguishing a `node -e` isolated
function call from a real end-to-end spawn of the test runner itself,
despite each coinciding numerically with an unrelated existing
constant), and EXEC_TOOL_OPTION_PASSTHROUGH_TIMEOUT_MS and
DISPATCH_FORCED_TIMEOUT_MS (shell-command-projection-dispatch.test.cjs
— a mocked-spawnSync pass-through fixture and a deliberately-forced
real timeout, neither a real subprocess bound in the usual sense).

Terminal-batch cleanup: deletes
eslint-rules/no-adhoc-timeout-literal.allowlist.json entirely, drops
its require and the allowlist option from eslint.config.mjs's
local/no-adhoc-timeout-literal registration (now a bare 'error',
mirroring local/no-unbounded-spawn's own already-terminal
configuration in the same file), and updates TESTING-STANDARDS.md's
enforcement note to match — a stale pointer to the deleted file caught
by review, fixed inline. A full-repo eslint run with no cache confirms
zero violations anywhere in the tree under the now allowlist-free rule.

Co-authored-by: sim <sim@local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-09-13 03:44:51 -04:00
committed by GitHub
parent a841575037
commit ccb39aec15
7 changed files with 57 additions and 21 deletions

View File

@@ -35,6 +35,23 @@ const {
const { createTempGitProject, createTempDir, cleanup } = require('./helpers.cjs');
/**
* NOT a subprocess timeout -- childProcess.spawnSync is fully mocked in
* this test, so no real spawn ever runs. Arbitrary fixture value proving
* execTool forwards its caller-supplied `timeout` option to spawnSync
* verbatim (a pass-through assertion, not a timing assertion).
*/
const EXEC_TOOL_OPTION_PASSTHROUGH_TIMEOUT_MS = 1234;
/**
* Deliberately far smaller than any real dispatchGsdCommand invocation
* could complete, forcing a genuine wall-clock timeout so this test can
* assert timedOut:true is reported correctly (mirrors the
* RUN_BASH_SCRIPT_FORCED_TIMEOUT_MS / BOUNDED_SHELL_FORCED_TIMEOUT_MS
* pattern used elsewhere in this migration).
*/
const DISPATCH_FORCED_TIMEOUT_MS = 1;
// ─── execGit ─────────────────────────────────────────────────────────────────
describe('execGit', () => {
@@ -1114,10 +1131,10 @@ describe('execTool (#3411 windows resolution)', () => {
});
t.after(() => mock.restoreAll());
execTool('some-tool', [], { cwd: '/tmp/x', env: { FOO: 'bar' }, timeout: 1234 });
execTool('some-tool', [], { cwd: '/tmp/x', env: { FOO: 'bar' }, timeout: EXEC_TOOL_OPTION_PASSTHROUGH_TIMEOUT_MS });
assert.equal(receivedOptions.cwd, '/tmp/x');
assert.equal(receivedOptions.timeout, 1234);
assert.equal(receivedOptions.timeout, EXEC_TOOL_OPTION_PASSTHROUGH_TIMEOUT_MS);
assert.equal(receivedOptions.env.FOO, 'bar');
// Case-insensitive: process.env's actual key casing is OS-dependent (Windows
// conventionally sets `Path`, not `PATH`), and the merged object here is a
@@ -1198,7 +1215,7 @@ describe('dispatchGsdCommand', () => {
test('a wall-clock timeout is reported via timedOut:true, ok:false — never throws', () => {
assert.doesNotThrow(() => {
const result = dispatchGsdCommand({ family: 'progress', subcommand: 'json', cwd: tmpDir, timeout: 1 });
const result = dispatchGsdCommand({ family: 'progress', subcommand: 'json', cwd: tmpDir, timeout: DISPATCH_FORCED_TIMEOUT_MS });
assert.equal(result.ok, false);
assert.equal(result.timedOut, true);
});