test(#1971): consolidate 48 gsd-tools CLI regression tests into subcommand suites

Fold 48 issue-named gsd-tools CLI regression files into the canonical test file
that owns each subcommand subject (state, roadmap, phase, milestone, audit, config,
router/dispatch, stats, verify, health, etc.), preserving every assertion and its
origin issue number as provenance (block-scoped describe wrappers, 299 subtests
conserved 1:1). No monolithic gsd-tools.test.cjs created — routes into 18 existing
per-subject suites.

Removes 48 tests/ files. Regenerates regression-name allowlist (271->231), ratchets
the file-count allowlist across 6 buckets (audit/milestone/phase/roadmap/state/verify),
and makes 10 relocated allow-test-rule exemptions issue-ref-compliant (ADR-456; prunes
10 stale ids). Repoints one CONTEXT.md symptom ref and ADR-3524's parity-test ref.
lint:ci green.

Part of epic #1969. Closes #1971.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-07-03 01:22:41 -04:00
parent 89ecee06fc
commit de3ba45d00
71 changed files with 10731 additions and 10317 deletions

View File

@@ -352,3 +352,139 @@ describe('generate-claude-md skills section', () => {
assert.ok(skillsIdx < workflowIdx, 'Skills section should come before Workflow Enforcement');
});
});
// ────────────────────────────────────────────────────────────────────────
// Folded from tests/bug-3163-codex-agents-md.test.cjs — consolidation epic #1969 (B2 #1971)
// ────────────────────────────────────────────────────────────────────────
{
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:bug-3163-codex-agents-md (consolidation epic #1969 B2 #1971)", () => {
'use strict';
/**
* Bug #3163: generate-claude-md should write to AGENTS.md on Codex runtime.
*
* When config.runtime === 'codex' (or GSD_RUNTIME=codex), the generate-claude-md
* handler must resolve the output path to AGENTS.md, not CLAUDE.md.
*/
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
describe('bug #3163: generate-claude-md uses AGENTS.md for Codex runtime', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
fs.writeFileSync(
path.join(tmpDir, '.planning', 'PROJECT.md'),
'# Test Project\n\nA Codex-hosted project.\n',
'utf-8'
);
});
afterEach(() => {
cleanup(tmpDir);
});
test('writes to AGENTS.md when config.runtime is codex and no --output given', () => {
const configPath = path.join(tmpDir, '.planning', 'config.json');
fs.writeFileSync(
configPath,
JSON.stringify({ runtime: 'codex', claude_md_path: './CLAUDE.md' }),
'utf-8'
);
const result = runGsdTools('generate-claude-md', tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const parsed = JSON.parse(result.output);
const realTmpDir = fs.realpathSync(tmpDir);
const expectedAgentsPath = path.join(realTmpDir, 'AGENTS.md');
// The returned path must be AGENTS.md, not CLAUDE.md
assert.strictEqual(parsed.claude_md_path, expectedAgentsPath,
`Expected output path to be AGENTS.md but got: ${parsed.claude_md_path}`
);
// AGENTS.md must exist on disk
assert.ok(fs.existsSync(expectedAgentsPath), 'AGENTS.md must exist after generation');
// CLAUDE.md must NOT be created
assert.ok(!fs.existsSync(path.join(realTmpDir, 'CLAUDE.md')), 'CLAUDE.md must not be created for Codex runtime');
});
test('writes to AGENTS.md when GSD_RUNTIME=codex env var is set (env takes precedence over config)', () => {
const configPath = path.join(tmpDir, '.planning', 'config.json');
// Config says runtime: claude but env overrides to codex
fs.writeFileSync(
configPath,
JSON.stringify({ runtime: 'claude', claude_md_path: './CLAUDE.md' }),
'utf-8'
);
const result = runGsdTools('generate-claude-md', tmpDir, { HOME: tmpDir, GSD_RUNTIME: 'codex' });
assert.ok(result.success, `Command failed: ${result.error}`);
const parsed = JSON.parse(result.output);
const realTmpDir = fs.realpathSync(tmpDir);
const expectedAgentsPath = path.join(realTmpDir, 'AGENTS.md');
assert.strictEqual(parsed.claude_md_path, expectedAgentsPath,
`Expected output path to be AGENTS.md but got: ${parsed.claude_md_path}`
);
assert.ok(fs.existsSync(expectedAgentsPath), 'AGENTS.md must exist after generation');
assert.ok(!fs.existsSync(path.join(realTmpDir, 'CLAUDE.md')), 'CLAUDE.md must not be created when GSD_RUNTIME=codex');
});
test('--output flag overrides runtime detection when explicitly provided', () => {
const configPath = path.join(tmpDir, '.planning', 'config.json');
fs.writeFileSync(
configPath,
JSON.stringify({ runtime: 'codex', claude_md_path: './CLAUDE.md' }),
'utf-8'
);
// When --output is explicitly provided, it must be honoured regardless of runtime
const result = runGsdTools(
['generate-claude-md', '--output', 'EXPLICIT-OUTPUT.md'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
const parsed = JSON.parse(result.output);
const realTmpDir = fs.realpathSync(tmpDir);
assert.strictEqual(
parsed.claude_md_path,
path.join(realTmpDir, 'EXPLICIT-OUTPUT.md'),
`Expected explicit --output to be honoured, got: ${parsed.claude_md_path}`
);
});
test('non-codex runtime still writes to CLAUDE.md', () => {
const configPath = path.join(tmpDir, '.planning', 'config.json');
fs.writeFileSync(
configPath,
JSON.stringify({ runtime: 'claude', claude_md_path: './CLAUDE.md' }),
'utf-8'
);
const result = runGsdTools('generate-claude-md', tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const parsed = JSON.parse(result.output);
const realTmpDir = fs.realpathSync(tmpDir);
assert.strictEqual(
parsed.claude_md_path,
path.join(realTmpDir, 'CLAUDE.md'),
`Expected CLAUDE.md for claude runtime, got: ${parsed.claude_md_path}`
);
assert.ok(fs.existsSync(path.join(realTmpDir, 'CLAUDE.md')), 'CLAUDE.md must exist for claude runtime');
assert.ok(!fs.existsSync(path.join(realTmpDir, 'AGENTS.md')), 'AGENTS.md must not be created for claude runtime');
});
});
});
}