* feat(#3545): widen no-source-grep with one-hop path-fold and hooks dir Resolve a readFileSync() path argument that is a bare Identifier one hop back to its VariableDeclarator initializer before classification, and recognize `hooks` as a source directory alongside bin/lib/gsd-core/src. Measured (epic #3464 phase 7): fold+hooks together newly flag 76 unsuppressed sites across 18 files that were previously invisible to identifier-indirected or hooks/-rooted source reads. Neither widening alone is sufficient — hooks-only surfaces 0 new sites, confirming #3520's prior finding that the identifier-indirection gap must close first. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * test(#3545): migrate 76 sites newly flagged by the fold+hooks widening Per-site classification: rewrite behaviorally (require() the real module, assert on its actual exported behavior) wherever the read was a proxy for code behavior; add a site-scoped `// allow-test-rule: <reason> (#3545)` marker only where the raw source text genuinely is the product under test (codex-config.test.cjs's adapter-header-contract checks, install.js structural-wiring guards with no exported symbol, AST-parse fixture inputs, etc.) — each marker cites an existing repo-sanctioned category from CONTRIBUTING.md's allow-test-rule exception table. Also converts two try/finally test bodies (introduced during this same migration) to the required t.after() cleanup pattern per CONTRIBUTING.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore(#3545): re-baseline effective-exemption ceiling to 81 The fold+hooks widening's own newly-detected sites are now suppressed by site-scoped markers, moving them from invisible into the tightly-ratcheted effective-exemption count. Ceiling rises from 10 to 81 (the exact measured high-water mark, grace unchanged at 2) — a deliberate, measured re-baseline per the widening working as intended, not an ordinary ceiling bump. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#3545): use canonical allow-test-rule category tokens 4 markers added during migration cited an issue ref correctly but didn't use one of CONTRIBUTING.md's seven recognized category tokens, unlike every other marker in this change. Cosmetic only — same suppression lines, same effective/live counts (81/81, 0 live). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#3545): correct stale phase-artifact path in test comment 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:
@@ -147,22 +147,35 @@ describe('stripJsonComments (#1461)', () => {
|
||||
});
|
||||
|
||||
describe('readSettings null return on malformed files (#1461)', () => {
|
||||
test('install.js contains JSONC stripping in readSettings', () => {
|
||||
const installPath = path.join(__dirname, '..', 'bin', 'install.js');
|
||||
const content = fs.readFileSync(installPath, 'utf8');
|
||||
assert.ok(content.includes('stripJsonComments'),
|
||||
'install.js should use stripJsonComments in readSettings');
|
||||
test('readSettings strips JSONC comments when reading a real file', (t) => {
|
||||
const tmpFile = path.join(os.tmpdir(), `gsd-settings-test-jsonc-${process.pid}.json`);
|
||||
fs.writeFileSync(tmpFile, `{\n // a comment\n "key": "value"\n}`);
|
||||
t.after(() => fs.unlinkSync(tmpFile));
|
||||
const result = readSettings(tmpFile);
|
||||
assert.deepStrictEqual(
|
||||
result,
|
||||
{ key: 'value' },
|
||||
'readSettings should use stripJsonComments so a commented file parses, not warns-as-malformed'
|
||||
);
|
||||
});
|
||||
|
||||
test('readSettings returns null on truly malformed files (not empty object)', () => {
|
||||
const installPath = path.join(__dirname, '..', 'bin', 'install.js');
|
||||
const content = fs.readFileSync(installPath, 'utf8');
|
||||
assert.ok(content.includes('return null'),
|
||||
'readSettings should return null on parse failure, not empty object');
|
||||
test('readSettings returns null on truly malformed files (not empty object)', (t) => {
|
||||
const tmpFile = path.join(os.tmpdir(), `gsd-settings-test-malformed-return-${process.pid}.json`);
|
||||
fs.writeFileSync(tmpFile, '{ this is not valid json');
|
||||
t.after(() => fs.unlinkSync(tmpFile));
|
||||
const result = readSettings(tmpFile);
|
||||
assert.strictEqual(result, null, 'readSettings should return null on parse failure, not empty object');
|
||||
});
|
||||
|
||||
test('callers guard against null readSettings return', () => {
|
||||
const installPath = path.join(__dirname, '..', 'bin', 'install.js');
|
||||
// allow-test-rule: structural-implementation-guard (#1461) (#3545) — structural
|
||||
// assertion on internal wiring inside install()'s (~2500-line)
|
||||
// settings-configuration call sites — the
|
||||
// null-guard only manifests behaviorally deep inside a full install()
|
||||
// run, so the source-text check is the minimum-cost regression guard
|
||||
// that a caller was not added without also checking readSettings'
|
||||
// documented null return
|
||||
const content = fs.readFileSync(installPath, 'utf8');
|
||||
// Should have null guards at the settings configuration call sites
|
||||
assert.ok(
|
||||
@@ -180,13 +193,16 @@ describe('readSettings null return on malformed files (#1461)', () => {
|
||||
// the behavioural ones beneath it.
|
||||
|
||||
describe('readSettings: JSON null coalesced to empty, malformed warns (#1191)', () => {
|
||||
test('source contains the null-coalescing guard (parsed === null ? {})', () => {
|
||||
// Structural anchor: if someone removes the coalescing, this test catches it
|
||||
// before the behavioural test below even runs.
|
||||
const installPath = path.join(__dirname, '..', 'bin', 'install.js');
|
||||
const content = fs.readFileSync(installPath, 'utf8');
|
||||
assert.ok(
|
||||
content.includes('parsed === null ? {}'),
|
||||
test('valid JSON null coalesces to {} via the real function (early behavioral anchor)', (t) => {
|
||||
// Behavioral anchor: if someone removes the coalescing, this test catches
|
||||
// it before the more detailed behavioural test below even runs.
|
||||
const tmpFile = path.join(os.tmpdir(), `gsd-settings-test-null-anchor-${process.pid}.json`);
|
||||
fs.writeFileSync(tmpFile, 'null');
|
||||
t.after(() => fs.unlinkSync(tmpFile));
|
||||
const result = readSettings(tmpFile);
|
||||
assert.deepStrictEqual(
|
||||
result,
|
||||
{},
|
||||
'install.js readSettings must coalesce valid JSON null to {} (not malformed warning)'
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user