mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 22:48:57 +02:00
fix(test): update four main-side assertions to the T3 installer contracts
Integration drift from the T3 lane: three static assertions pinned the OLD implementation shapes that T3 legitimately replaced — the gbrain-refresh branch no longer self-documents a reset --hard cycle (#2569 renders to an untracked out-dir instead; the test now pins THAT), setup's regen block renamed to the render form (re-anchored, same exit-code-propagation invariant), and sections/ linking generalized into _link_skill_runtime_assets (the _link_or_copy routing assertion moved into the helper). Fourth: the uninstall neutral-target test asserted against os.tmpdir(), which reads $TMPDIR at call time — a shard neighbor can leave it gstack-containing, making the "neutral" symlink target match the provenance substring; the test now falls back to a fixed neutral root and asserts neutrality explicitly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
d889453686
commit
5b65f91a8c
@@ -44,13 +44,18 @@ describe('gstack-config gbrain-refresh: machine-wide render guards', () => {
|
||||
expect(branch).toContain('command -v bun');
|
||||
});
|
||||
|
||||
test('renders the :user variant in place into the install', () => {
|
||||
test('renders the :user variant for the claude host', () => {
|
||||
expect(branch).toContain('gen:skill-docs:user --host claude');
|
||||
});
|
||||
|
||||
test('is self-documenting about the reset --hard / re-run cycle', () => {
|
||||
expect(branch).toContain('reset --hard');
|
||||
expect(branch).toContain('gbrain-refresh');
|
||||
// #2569: the render goes to an UNTRACKED out-dir, never in place — the old
|
||||
// in-place render dirtied the install checkout on every refresh, and this
|
||||
// branch used to self-document a reset --hard / re-run cycle as the
|
||||
// workaround. The out-dir render makes that cycle unnecessary.
|
||||
test('renders to an untracked out-dir, never in place (#2569)', () => {
|
||||
expect(branch).toContain('--out-dir');
|
||||
expect(branch).toContain('render/claude');
|
||||
expect(branch).not.toContain('reset --hard');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -45,16 +45,19 @@ describe('setup: gen:skill-docs:user exit-code propagation (pipe-masking fix)',
|
||||
expect(r.stdout).not.toContain('LOG: warning');
|
||||
});
|
||||
|
||||
test('setup: the live gbrain regen block has no pipe before the || guard', () => {
|
||||
test('setup: the live gbrain render block has no pipe masking its exit code', () => {
|
||||
// Slice the exact block from setup and confirm the fix is in place
|
||||
// without resorting to a fragile line-number check.
|
||||
const start = SETUP_SRC.indexOf('gbrain detected — regenerating');
|
||||
// without resorting to a fragile line-number check. (#2569 renamed the
|
||||
// block from "regenerating" to "rendering ... into $_GSTACK_RENDER_DIR" —
|
||||
// the exit-code-propagation invariant is unchanged.)
|
||||
const start = SETUP_SRC.indexOf('gbrain detected — rendering');
|
||||
expect(start).toBeGreaterThan(-1);
|
||||
const end = SETUP_SRC.indexOf('|| log', start);
|
||||
const end = SETUP_SRC.indexOf('warning: gen:skill-docs:user failed', start);
|
||||
expect(end).toBeGreaterThan(start);
|
||||
const block = SETUP_SRC.slice(start, end);
|
||||
expect(block).toContain('bun_cmd run gen:skill-docs:user --host claude');
|
||||
// The bug shape: `... | tail -N` between the call and the `|| log` guard.
|
||||
// The bug shape: `... | tail -N` between the call and the failure guard —
|
||||
// a pipe would replace the render's exit code with tail's.
|
||||
expect(block).not.toMatch(/gen:skill-docs:user[^\n]*\|\s*tail/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,12 +24,17 @@ function fnBody(src: string, name: string): string {
|
||||
}
|
||||
|
||||
describe('setup links sections/ for cherry-pick install targets', () => {
|
||||
test('link_claude_skill_dirs links sections/ via _link_or_copy', () => {
|
||||
test('link_claude_skill_dirs installs runtime assets (incl. sections/) via the shared helper', () => {
|
||||
// #2317/#2454 generalized the sections/-only install into
|
||||
// _link_skill_runtime_assets, which carries EVERY runtime asset a skill
|
||||
// references (sections/, checklist.md, specialists/, ...). That helper
|
||||
// routes through _link_or_copy internally (windows-safe), so the old
|
||||
// per-directory _link_or_copy assertion moved there.
|
||||
const body = fnBody(SETUP, 'link_claude_skill_dirs');
|
||||
expect(body).toContain('sections');
|
||||
// sections install must route through the windows-safe helper, not raw ln.
|
||||
expect(body).toMatch(/_link_or_copy\s+"\$gstack_dir\/\$dir_name\/sections"\s+"\$target\/sections"/);
|
||||
expect(body).toMatch(/if \[ -d "\$gstack_dir\/\$dir_name\/sections" \]/);
|
||||
expect(body).toMatch(/_link_skill_runtime_assets\s+"\$gstack_dir\/\$dir_name"\s+"\$target"/);
|
||||
const helper = fnBody(SETUP, '_link_skill_runtime_assets');
|
||||
expect(helper).toContain('_link_or_copy');
|
||||
expect(helper).not.toMatch(/\bln -s/);
|
||||
});
|
||||
|
||||
test('kiro per-skill loop rewrites + copies sections/*', () => {
|
||||
|
||||
@@ -151,8 +151,17 @@ describe.skipIf(process.platform === 'win32')(
|
||||
test('SKILL.md symlink pointing elsewhere → kept and listed', () => {
|
||||
// Target path must not contain "gstack" anywhere (the provenance match
|
||||
// is a substring check, mirroring setup's cleanup helpers) — the suite
|
||||
// tmpdir prefix does, so use a separate neutral tmpdir.
|
||||
const neutral = fs.mkdtempSync(path.join(os.tmpdir(), 'other-skill-src-'));
|
||||
// tmpdir prefix does, so use a separate neutral tmpdir. os.tmpdir()
|
||||
// reads $TMPDIR at CALL time, and in shared-process shard runs a
|
||||
// neighboring test can leave it pointing at a gstack-containing path —
|
||||
// observed once in a full-suite shard (the "neutral" target then
|
||||
// matched the provenance substring and the dir was wrongly deleted by
|
||||
// the test's own expectations). Fall back to a fixed neutral root and
|
||||
// ASSERT neutrality so the precondition can never silently rot.
|
||||
let neutralRoot = os.tmpdir();
|
||||
if (neutralRoot.includes('gstack')) neutralRoot = '/private' + path.sep + 'tmp';
|
||||
const neutral = fs.mkdtempSync(path.join(neutralRoot, 'other-skill-src-'));
|
||||
expect(neutral.includes('gstack')).toBe(false);
|
||||
const elsewhere = path.join(neutral, 'elsewhere.md');
|
||||
fs.writeFileSync(elsewhere, '# not ours\n');
|
||||
const dir = path.join(skillsDir, 'someone-elses');
|
||||
|
||||
Reference in New Issue
Block a user