* test(#3144): bound the git/worktree cluster onto the process seam Migrates 180 unbounded sync spawn sites across 19 files. Every previously unbounded call now carries an explicit timeout with a comment giving the number and why. The migration is not a callee swap. execSync and execFileSync throw on a non-zero exit and the seam never does, so each site was classified first: sites that rely on the throw route to gitOrThrow, and sites that already read .status to detect an EXPECTED non-zero -- an intended cherry-pick conflict, a rev-parse outside a repo driving a skip -- route to the never-throwing runGit instead, which would otherwise throw on exactly the exit being probed for. Two same-named git() helpers in worktree-cleanup.test.cjs have different return contracts, one trimmed and one raw; both are preserved rather than unified. Collapses five hand-rolled throw wrappers onto one throwIfFailed in git-fixture.cjs, which gitOrThrow now also uses so the shape cannot drift. Allowlist drops 139 to 120; BASELINE lowered to match. * test(#3144): fix pre-PR review findings Documents throwIfFailed in the CONTEXT.md glossary and CONTRIBUTING.md -- it became the shared throw mechanism without either doc naming it. Routes the sixth and seventh hand-rolled copies of the throw shape through throwIfFailed (worktree-baseref-install, worktree-safety-reap); the first consolidation missed both. Converts ci-rebase-check's 8 fixture-setup calls from unchecked runGit to gitOrThrow so a failed setup step aborts where it fails rather than surfacing later as a confusing failure against the wrong subject. Adds 12 direct unit tests for throwIfFailed, which until now was only exercised transitively. Splits verify.test.cjs's non-git grep/sed bound off GIT_TIMEOUT_MS. --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -28,6 +28,8 @@ const path = require('node:path');
|
||||
const os = require('node:os');
|
||||
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
const { runGit: seamRunGit, OUTCOME } = require('./helpers/process-seam.cjs');
|
||||
const { gitOrThrow } = require('./helpers/git-fixture.cjs');
|
||||
|
||||
const {
|
||||
VERIFIER_STATUSES,
|
||||
@@ -36,6 +38,11 @@ const {
|
||||
readVerificationStatus,
|
||||
} = require('../gsd-core/bin/lib/verification.cjs');
|
||||
|
||||
// 15000ms: git plumbing (init/config/add/commit) against a small mkdtemp
|
||||
// fixture repo, plus a `git --version` availability probe — gitOrThrow's own
|
||||
// documented default, reused here as this file's named constant.
|
||||
const GIT_TIMEOUT_MS = 15000;
|
||||
|
||||
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
@@ -407,12 +414,10 @@ describe('verification-status', () => {
|
||||
|
||||
// git availability for the real-subprocess integration test below.
|
||||
const GIT_AVAILABLE = (() => {
|
||||
try {
|
||||
require('node:child_process').execFileSync('git', ['--version'], { stdio: 'ignore' });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
// Soft probe — a missing/broken git binary must resolve to `false`, not
|
||||
// throw, so seamRunGit is used directly rather than gitOrThrow.
|
||||
const r = seamRunGit(['--version'], { timeoutMs: GIT_TIMEOUT_MS });
|
||||
return r.outcome === OUTCOME.EXITED && r.exitCode === 0;
|
||||
})();
|
||||
|
||||
test('committed passed verification is NOT stale from mtime skew alone when the summary was not committed later (#2348)', () => {
|
||||
@@ -605,12 +610,11 @@ describe('verification-status', () => {
|
||||
'real git: a summary committed after the verification reads stale via the real git clock, even for a dash-named file (#2348 end-to-end + `--` argv guard)',
|
||||
{ skip: GIT_AVAILABLE ? false : 'git binary not available' },
|
||||
() => {
|
||||
const { execFileSync } = require('node:child_process');
|
||||
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2348-realgit-'));
|
||||
const runGit = (args, extraEnv) =>
|
||||
execFileSync('git', args, {
|
||||
gitOrThrow(args, {
|
||||
cwd: repo,
|
||||
stdio: 'pipe',
|
||||
timeoutMs: GIT_TIMEOUT_MS,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0', ...(extraEnv || {}) },
|
||||
});
|
||||
const commitEnvAt = (iso) => ({ GIT_AUTHOR_DATE: iso + '+00:00', GIT_COMMITTER_DATE: iso + '+00:00' });
|
||||
@@ -658,12 +662,11 @@ describe('verification-status', () => {
|
||||
'real git: a committed summary edited on disk (dirty) reads stale via mtime, not shadowed by its commit time (#2348 dirty regression, end-to-end)',
|
||||
{ skip: GIT_AVAILABLE ? false : 'git binary not available' },
|
||||
() => {
|
||||
const { execFileSync } = require('node:child_process');
|
||||
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2348-realgit-dirty-'));
|
||||
const runGit = (args, extraEnv) =>
|
||||
execFileSync('git', args, {
|
||||
gitOrThrow(args, {
|
||||
cwd: repo,
|
||||
stdio: 'pipe',
|
||||
timeoutMs: GIT_TIMEOUT_MS,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0', ...(extraEnv || {}) },
|
||||
});
|
||||
const commitEnvAt = (iso) => ({ GIT_AUTHOR_DATE: iso + '+00:00', GIT_COMMITTER_DATE: iso + '+00:00' });
|
||||
|
||||
Reference in New Issue
Block a user