test(#1972): consolidate 94 command/module regression tests into subject suites
Fold 94 issue-named command/module regression files into the canonical test file that owns each subject-under-test, across 52 existing suites (state, config, frontmatter, roadmap-parser, capability-registry, shell-command-projection-dispatch, plan-phase-drift-guard, health-validation, runtime-converters, commands, etc.). Verbatim block-scoped describe wrappers; 881 subtests conserved 1:1. No new test files. Host-env pre-check (per B2): the only GSD_WORKSTREAM/GSD_PROJECT-touching destinations (intel, planning-workspace) clear those vars hermetically, so folded CLI tests are safe. Regenerates regression-name allowlist (222->162), ratchets file-count allowlist across 8 buckets (validate entry removed after dropping <=2), makes 34 relocated allow-test-rule exemptions issue-ref-compliant (ADR-456; prunes 34 stale ids). Repoints CONTEXT.md + ADR-0002/443/1235/3524 test-file references. lint:ci green. Part of epic #1969. Closes #1972. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -518,3 +518,156 @@ describe('_deepMergeConfig — prototype-pollution guard (M4)', () => {
|
||||
assert.equal(typeof merged.constructor, 'function');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// Folded from tests/bug-2638-sub-repos-canonical-location.test.cjs — consolidation epic #1969 (B3 #1972)
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
{
|
||||
const { describe: __foldDescribe } = require('node:test');
|
||||
__foldDescribe("folded:bug-2638-sub-repos-canonical-location (consolidation epic #1969 B3 #1972)", () => {
|
||||
/**
|
||||
* Regression test for bug #2638.
|
||||
*
|
||||
* loadConfig previously migrated/synced sub_repos to the TOP-LEVEL
|
||||
* `parsed.sub_repos`, but the KNOWN_TOP_LEVEL allowlist only recognizes
|
||||
* `planning.sub_repos` (per #2561 — canonical location). That asymmetry
|
||||
* made loadConfig write a key it then warns is unknown on the next read.
|
||||
*
|
||||
* Fix: writers target `parsed.planning.sub_repos` and strip any stale
|
||||
* top-level copy during the same migration pass.
|
||||
*/
|
||||
|
||||
const { test, describe, beforeEach, afterEach } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { execFileSync } = require('child_process');
|
||||
const { createTempProject, cleanup } = require('./helpers.cjs');
|
||||
|
||||
const { loadConfig } = require('../gsd-core/bin/lib/config-loader.cjs');
|
||||
|
||||
function makeSubRepo(parent, name) {
|
||||
const dir = path.join(parent, name);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
execFileSync('git', ['init'], { cwd: dir, stdio: 'pipe' });
|
||||
}
|
||||
|
||||
function readConfig(tmpDir) {
|
||||
return JSON.parse(
|
||||
fs.readFileSync(path.join(tmpDir, '.planning', 'config.json'), 'utf-8')
|
||||
);
|
||||
}
|
||||
|
||||
function writeConfig(tmpDir, obj) {
|
||||
fs.writeFileSync(
|
||||
path.join(tmpDir, '.planning', 'config.json'),
|
||||
JSON.stringify(obj, null, 2)
|
||||
);
|
||||
}
|
||||
|
||||
describe('bug #2638 — sub_repos canonical location', () => {
|
||||
let tmpDir;
|
||||
let originalCwd;
|
||||
let stderrCapture;
|
||||
let origStderrWrite;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempProject();
|
||||
originalCwd = process.cwd();
|
||||
stderrCapture = '';
|
||||
origStderrWrite = process.stderr.write;
|
||||
process.stderr.write = (chunk) => { stderrCapture += chunk; return true; };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.stderr.write = origStderrWrite;
|
||||
process.chdir(originalCwd);
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('does not warn when planning.sub_repos is set (no top-level sub_repos)', () => {
|
||||
makeSubRepo(tmpDir, 'backend');
|
||||
makeSubRepo(tmpDir, 'frontend');
|
||||
writeConfig(tmpDir, {
|
||||
planning: { sub_repos: ['backend', 'frontend'] },
|
||||
});
|
||||
|
||||
loadConfig(tmpDir);
|
||||
|
||||
assert.ok(
|
||||
!stderrCapture.includes('unknown config key'),
|
||||
`should not warn for planning.sub_repos, got: ${stderrCapture}`
|
||||
);
|
||||
assert.ok(
|
||||
!stderrCapture.includes('sub_repos'),
|
||||
`should not mention sub_repos at all, got: ${stderrCapture}`
|
||||
);
|
||||
});
|
||||
|
||||
test('migrates legacy multiRepo:true into planning.sub_repos (not top-level)', () => {
|
||||
makeSubRepo(tmpDir, 'backend');
|
||||
makeSubRepo(tmpDir, 'frontend');
|
||||
writeConfig(tmpDir, { multiRepo: true });
|
||||
|
||||
loadConfig(tmpDir);
|
||||
|
||||
const after = readConfig(tmpDir);
|
||||
assert.deepStrictEqual(
|
||||
after.planning?.sub_repos,
|
||||
['backend', 'frontend'],
|
||||
'migration should write to planning.sub_repos'
|
||||
);
|
||||
assert.strictEqual(
|
||||
Object.prototype.hasOwnProperty.call(after, 'sub_repos'),
|
||||
false,
|
||||
'migration must not leave a top-level sub_repos key'
|
||||
);
|
||||
assert.strictEqual(after.multiRepo, undefined, 'legacy multiRepo should be removed');
|
||||
|
||||
assert.ok(
|
||||
!stderrCapture.includes('unknown config key'),
|
||||
`post-migration read should not warn, got: ${stderrCapture}`
|
||||
);
|
||||
});
|
||||
|
||||
test('filesystem sync writes detected list to planning.sub_repos only', () => {
|
||||
makeSubRepo(tmpDir, 'api');
|
||||
makeSubRepo(tmpDir, 'web');
|
||||
writeConfig(tmpDir, { planning: { sub_repos: ['api'] } });
|
||||
|
||||
loadConfig(tmpDir);
|
||||
|
||||
const after = readConfig(tmpDir);
|
||||
assert.deepStrictEqual(after.planning?.sub_repos, ['api', 'web']);
|
||||
assert.strictEqual(
|
||||
Object.prototype.hasOwnProperty.call(after, 'sub_repos'),
|
||||
false,
|
||||
'sync must not create a top-level sub_repos key'
|
||||
);
|
||||
assert.ok(
|
||||
!stderrCapture.includes('unknown config key'),
|
||||
`sync should not produce unknown-key warning, got: ${stderrCapture}`
|
||||
);
|
||||
});
|
||||
|
||||
test('stale top-level sub_repos is stripped on load', () => {
|
||||
makeSubRepo(tmpDir, 'backend');
|
||||
writeConfig(tmpDir, {
|
||||
sub_repos: ['backend'],
|
||||
planning: { sub_repos: ['backend'] },
|
||||
});
|
||||
|
||||
loadConfig(tmpDir);
|
||||
|
||||
const after = readConfig(tmpDir);
|
||||
assert.strictEqual(
|
||||
Object.prototype.hasOwnProperty.call(after, 'sub_repos'),
|
||||
false,
|
||||
'stale top-level sub_repos should be removed to self-heal legacy installs'
|
||||
);
|
||||
assert.deepStrictEqual(after.planning?.sub_repos, ['backend']);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user