mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-31 18:30:39 +02:00
fix(test): spec-template-sync compares an out-dir render, not an in-place one
TREE_MUTATING entry deleted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
dfb5b61889
commit
9887f4c769
@@ -388,7 +388,6 @@ export const WORKER_HOSTILE: Record<string, string> = {
|
|||||||
* a renamed file fails the suite instead of silently dropping serialization.
|
* a renamed file fails the suite instead of silently dropping serialization.
|
||||||
*/
|
*/
|
||||||
export const TREE_MUTATING: Record<string, string> = {
|
export const TREE_MUTATING: Record<string, string> = {
|
||||||
'test/spec-template-sync.test.ts': 'regenerates all SKILL.md in place to compare spec/SKILL.md',
|
|
||||||
// Ratchet readers (measure the tree; need it quiet):
|
// Ratchet readers (measure the tree; need it quiet):
|
||||||
'test/parity-suite.test.ts': 'RATCHET READER — parity caps measure live SKILL.md/section bytes',
|
'test/parity-suite.test.ts': 'RATCHET READER — parity caps measure live SKILL.md/section bytes',
|
||||||
'test/skill-size-budget.test.ts': 'RATCHET READER — per-skill and corpus size budgets measure the live tree',
|
'test/skill-size-budget.test.ts': 'RATCHET READER — per-skill and corpus size budgets measure the live tree',
|
||||||
|
|||||||
@@ -7,9 +7,13 @@
|
|||||||
* /spec is carved (skeleton + sections/gate-and-file.md), so BOTH generated
|
* /spec is carved (skeleton + sections/gate-and-file.md), so BOTH generated
|
||||||
* artifacts are checked: a stale section is the same drift bug as a stale
|
* artifacts are checked: a stale section is the same drift bug as a stale
|
||||||
* skeleton — the on-demand file is what the agent executes at Phase 4.5.
|
* skeleton — the on-demand file is what the agent executes at Phase 4.5.
|
||||||
|
*
|
||||||
|
* The regen renders into an isolated --out-dir and compares the rendered
|
||||||
|
* bytes against the TRACKED files — the working tree is only ever read.
|
||||||
*/
|
*/
|
||||||
import { describe, test, expect } from 'bun:test';
|
import { describe, test, expect } from 'bun:test';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { spawnSync } from 'child_process';
|
import { spawnSync } from 'child_process';
|
||||||
|
|
||||||
@@ -22,9 +26,9 @@ const GENERATED_PATHS = [
|
|||||||
|
|
||||||
describe('/spec template/generated sync', () => {
|
describe('/spec template/generated sync', () => {
|
||||||
test('regenerating spec/SKILL.md + sections produces byte-identical output', () => {
|
test('regenerating spec/SKILL.md + sections produces byte-identical output', () => {
|
||||||
const before = GENERATED_PATHS.map((p) => fs.readFileSync(p));
|
const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-spec-sync-'));
|
||||||
|
|
||||||
const res = spawnSync('bun', ['run', 'gen:skill-docs'], {
|
const res = spawnSync('bun', ['run', 'gen:skill-docs', '--out-dir', outDir], {
|
||||||
cwd: ROOT,
|
cwd: ROOT,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
@@ -40,12 +44,24 @@ describe('/spec template/generated sync', () => {
|
|||||||
TMPDIR: process.env.TMPDIR ?? '',
|
TMPDIR: process.env.TMPDIR ?? '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(res.status).toBe(0);
|
try {
|
||||||
|
expect(res.status).toBe(0);
|
||||||
|
|
||||||
for (let i = 0; i < GENERATED_PATHS.length; i++) {
|
for (const trackedPath of GENERATED_PATHS) {
|
||||||
const after = fs.readFileSync(GENERATED_PATHS[i]);
|
const rel = path.relative(ROOT, trackedPath);
|
||||||
expect({ file: path.relative(ROOT, GENERATED_PATHS[i]), identical: after.equals(before[i]) })
|
const rendered = fs.readFileSync(path.join(outDir, rel), 'utf-8');
|
||||||
.toEqual({ file: path.relative(ROOT, GENERATED_PATHS[i]), identical: true });
|
// --out-dir repoints the literal section-base paths
|
||||||
|
// (~/.claude/skills/gstack/<skill>/sections/ → <outDir>/<skill>/sections/)
|
||||||
|
// so section Reads resolve inside the render. Undo that single
|
||||||
|
// documented rewrite before comparing; every OTHER byte must match
|
||||||
|
// the tracked file exactly.
|
||||||
|
const normalized = rendered.replaceAll(`${outDir}/`, '~/.claude/skills/gstack/');
|
||||||
|
const tracked = fs.readFileSync(trackedPath, 'utf-8');
|
||||||
|
expect({ file: rel, identical: normalized === tracked })
|
||||||
|
.toEqual({ file: rel, identical: true });
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(outDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
}, 130_000);
|
}, 130_000);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user