* test(#4515): migrate installer-runs batch to named timeout constants Batch 4 of the ad hoc timeout literal migration (epic #4445). Replaces every bare numeric timeout/timeoutMs object-literal property across tests/install.test.cjs, tests/install-minimal-hooks.test.cjs, tests/fragment-single-edit-propagation.install.test.cjs, tests/install-regressions.test.cjs, tests/install-runtime-artifacts.test.cjs, tests/npm-integrity-gate.test.cjs, tests/faulty-deps.test.cjs, tests/release-tarball-smoke.install.test.cjs, tests/install-write-confinement.test.cjs, tests/plugin-manifest.test.cjs, and tests/packaging-shipped-scripts-require-only-shipped.test.cjs with a named constant, per eslint-rules/no-adhoc-timeout-literal.cjs. Removes these 11 files from the rule's allowlist. Adds one new shared constant to tests/helpers/timeouts.cjs for a fixture-JSON value (in seconds, not ms) mimicking a Claude Code settings.json hook-entry's own timeout field, shared across two files in this batch. Every other new constant is file-local, each carrying a comment explaining why its call site is a distinct operational class from the existing shared norms even where its digits numerically coincide with one. No src/bin file touched, no numeric timeout value changed anywhere. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: combine gsd-worktree-path-guard's git rev-parse calls to cut subprocess count under CI load Discovered while verifying PR #4575 (a full test (windows-latest) failure in an unrelated test, tests/kilo-upgrades.test.cjs's worktree-path-guard rejection test). Root cause: this hook's up-to-4 sequential git spawns (git-dir, branch, worktree-toplevel, file-toplevel), invoked inside a native-plugin's own 8000ms-capped subprocess wrapper, left zero margin for node/git startup overhead — the guard is deliberately fail-open on any timeout, so CI-load-induced latency in this chain silently downgrades a security block into an allow. Combines the first three git rev-parse calls (git-dir, branch via --abbrev-ref, worktree-toplevel) into ONE spawn instead of three, using git's documented multi-flag rev-parse output (one line per flag, in order) — verified empirically including the detached-HEAD edge case. No timeout value changed; this reduces subprocess COUNT, not any tolerance. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs: add changeset fragment for the worktree-path-guard fix Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: sim <sim@local> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,20 @@ const { runNode } = require('./helpers/process-seam.cjs');
|
||||
const pkg = require('../package.json');
|
||||
|
||||
// #3145: class-norm timeout, not a per-suite value — see helpers/timeouts.cjs.
|
||||
const { PROBE_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
|
||||
const { PROBE_TIMEOUT_MS, QUICK_SPAWN_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
|
||||
|
||||
// Fixture-JSON value (seconds, not ms) simulating the PRE-migration legacy
|
||||
// settings.json hook-entry timeout under test (#3981-style migration test).
|
||||
// Deliberately a different value than the shared FIXTURE_HOOK_TIMEOUT_SECONDS
|
||||
// constant (5) since this site tests the old value specifically (batch #4515,
|
||||
// epic #4445).
|
||||
const FIXTURE_LEGACY_HOOK_TIMEOUT_SECONDS = 10;
|
||||
|
||||
// Bounds an `install.js --dry-run` run (no file writes) — a lighter shape than
|
||||
// the shared full-write INSTALL_TIMEOUT_MS class (120000ms), kept separate
|
||||
// rather than raised. Shared by both dry-run sites in this file (batch #4515,
|
||||
// epic #4445).
|
||||
const DRY_RUN_INSTALL_TIMEOUT_MS = 30_000;
|
||||
|
||||
const {
|
||||
getConfigDirFromHome,
|
||||
@@ -1127,7 +1140,7 @@ describe('install — fix-slash-commands.cjs lands at scripts/fix-slash-commands
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
[gsdToolsPath, 'query', 'init.new-project'],
|
||||
{ encoding: 'utf8', timeout: 15000 },
|
||||
{ encoding: 'utf8', timeout: PROBE_TIMEOUT_MS },
|
||||
);
|
||||
assert.ok(
|
||||
!result.stderr.includes('MODULE_NOT_FOUND'),
|
||||
@@ -1215,7 +1228,7 @@ describe('readCmdNames() — tolerates missing commands/gsd directory (#1223)',
|
||||
|
||||
const spawnResult = spawnSync(process.execPath, ['-e', script], {
|
||||
encoding: 'utf8',
|
||||
timeout: 10000,
|
||||
timeout: QUICK_SPAWN_TIMEOUT_MS,
|
||||
env: { ...process.env, GSD_TEST_MODE: '1' },
|
||||
});
|
||||
assert.ok(
|
||||
@@ -5568,7 +5581,7 @@ describe('#338 case 3: migration of prior local install GSD entries from setting
|
||||
{
|
||||
type: 'command',
|
||||
command: `${process.execPath} ${path.join(claudeDir, 'hooks', 'gsd-context-monitor.js')}`,
|
||||
timeout: 10,
|
||||
timeout: FIXTURE_LEGACY_HOOK_TIMEOUT_SECONDS,
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -7368,7 +7381,7 @@ function installAndRead(runtime) {
|
||||
const res = spawnSync(
|
||||
process.execPath,
|
||||
[INSTALL, `--${runtime}`, '--global', '--config-dir', dir],
|
||||
{ encoding: 'utf8', timeout: 120000, env: { ...process.env, HOME: dir, USERPROFILE: dir } },
|
||||
{ encoding: 'utf8', timeout: INSTALL_TIMEOUT_MS, env: { ...process.env, HOME: dir, USERPROFILE: dir } },
|
||||
);
|
||||
assert.strictEqual(res.status, 0, `install --${runtime} failed: ${res.stderr || res.stdout}`);
|
||||
const wf = path.join(dir, 'gsd-core', 'workflows', 'execute-phase.md');
|
||||
@@ -7809,7 +7822,7 @@ describe('#3026: installer --help documents every accepted runtime flag', () =>
|
||||
|
||||
test('every accepted runtime flag appears in --help output', () => {
|
||||
// Derive accepted flags behaviorally from the installer's argument parser.
|
||||
const r = spawnSync(process.execPath, [INSTALL_PATH, '--help'], { encoding: 'utf-8', timeout: 10000 });
|
||||
const r = spawnSync(process.execPath, [INSTALL_PATH, '--help'], { encoding: 'utf-8', timeout: QUICK_SPAWN_TIMEOUT_MS });
|
||||
const helpText = r.stdout;
|
||||
|
||||
// The installer's getRuntimeArgs defines which --<runtime> flags it accepts.
|
||||
@@ -7976,7 +7989,7 @@ describe('#607 --dry-run flag: spawned installer exits 0 and mutates nothing', (
|
||||
},
|
||||
cwd: REPO_ROOT,
|
||||
encoding: 'utf8',
|
||||
timeout: 30_000,
|
||||
timeout: DRY_RUN_INSTALL_TIMEOUT_MS,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -8051,7 +8064,7 @@ describe('#607 --dry-run flag: spawned installer exits 0 and mutates nothing', (
|
||||
},
|
||||
cwd: REPO_ROOT,
|
||||
encoding: 'utf8',
|
||||
timeout: 30_000,
|
||||
timeout: DRY_RUN_INSTALL_TIMEOUT_MS,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user