fix(#2163): round-2 review fixes — deterministic fail-soft injection tests

- readGitStatus calls execFileSync via the child_process namespace so tests
  can inject spawn failures through the shared module object
- two deterministic tests: ERR_CHILD_PROCESS_STDOUT_MAXBUFFER-shaped and
  ETIMEDOUT-shaped throws both degrade to null (segment absent), proving
  the fail-soft paths the PR previously only asserted

Claude-Session: https://claude.ai/code/session_01Hme55Pvq6BhpgwBcyC5HAg
This commit is contained in:
Cody Anderson
2026-07-11 20:13:10 -06:00
parent 7a6564ed8a
commit 73039d3717
2 changed files with 39 additions and 2 deletions

View File

@@ -6,7 +6,9 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const { execFileSync } = require('child_process');
// Namespace (not destructured) so tests can inject spawn failures by
// monkeypatching childProcess.execFileSync.
const childProcess = require('child_process');
const { isSemverNewer } = require('../gsd-core/bin/lib/semver-compare.cjs');
const { PACKAGE_NAME, updateCacheFileName } = require('../gsd-core/bin/lib/package-identity.cjs');
@@ -339,7 +341,7 @@ function readGitStatus(dir) {
// 8 MiB maxBuffer (default 1 MiB) headroom for repos with very many changed
// or untracked files; overflow still degrades safely to segment-absent via
// the catch below.
return execFileSync('git', ['-C', dir, 'status', '--porcelain=v2', '--branch'],
return childProcess.execFileSync('git', ['-C', dir, 'status', '--porcelain=v2', '--branch'],
{ encoding: 'utf8', timeout: GIT_STATUS_TIMEOUT_MS, maxBuffer: 8 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] });
} catch (e) {
return null;