mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
00a7a65026
Six new gate-tier test files: - test/writing-style-resolver.test.ts — asserts Writing Style section is injected into tier-≥2 preamble, all 6 rules present, jargon list inlined, terse-mode gate condition present, Codex output uses \$GSTACK_BIN (not ~/.claude/), tier-1 does NOT get the section, migration-prompt block present. - test/explain-level-config.test.ts — gstack-config set/get round-trip for default + terse, unknown-value warns + defaults to default, header documents the key, round-trip across set→set→get. - test/jargon-list.test.ts — shape + ~50 terms + no duplicates (case-insensitive) + includes canonical high-signal terms. - test/v0-dormancy.test.ts — 5D dimension names + archetype names forbidden in default-mode tier-≥2 SKILL.md output, except for plan-tune and office-hours where they're load-bearing. - test/readme-throughput.test.ts — script replaces anchor with number on happy path, writes PENDING marker when JSON missing, CI gate asserts committed README contains no PENDING string. - test/upgrade-migration-v1.test.ts — fresh run writes pending flag, idempotent after user-answered, pre-existing explain_level counts as answered. All 95 V1 test-expect() calls pass. Full suite: 0 failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84 lines
2.9 KiB
TypeScript
84 lines
2.9 KiB
TypeScript
/**
|
|
* gstack-config explain_level round-trip + validation tests.
|
|
*
|
|
* Coverage:
|
|
* - `set explain_level default` persists, `get` returns "default"
|
|
* - `set explain_level terse` persists, `get` returns "terse"
|
|
* - `set explain_level garbage` warns + writes "default"
|
|
* - `get explain_level` with unset key returns empty (preamble bash defaults)
|
|
* - Annotated config header documents explain_level
|
|
*/
|
|
import { describe, test, expect, beforeEach, afterEach } from 'bun:test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as os from 'os';
|
|
import { spawnSync } from 'child_process';
|
|
|
|
const ROOT = path.resolve(import.meta.dir, '..');
|
|
const BIN_CONFIG = path.join(ROOT, 'bin', 'gstack-config');
|
|
|
|
let tmpHome: string;
|
|
|
|
beforeEach(() => {
|
|
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-cfg-test-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
});
|
|
|
|
function run(...args: string[]): { stdout: string; stderr: string; status: number } {
|
|
const res = spawnSync(BIN_CONFIG, args, {
|
|
env: { ...process.env, GSTACK_STATE_DIR: tmpHome },
|
|
encoding: 'utf-8',
|
|
cwd: ROOT,
|
|
});
|
|
return {
|
|
stdout: (res.stdout ?? '').trim(),
|
|
stderr: (res.stderr ?? '').trim(),
|
|
status: res.status ?? -1,
|
|
};
|
|
}
|
|
|
|
describe('gstack-config explain_level', () => {
|
|
test('set + get default round-trip', () => {
|
|
expect(run('set', 'explain_level', 'default').status).toBe(0);
|
|
expect(run('get', 'explain_level').stdout).toBe('default');
|
|
});
|
|
|
|
test('set + get terse round-trip', () => {
|
|
expect(run('set', 'explain_level', 'terse').status).toBe(0);
|
|
expect(run('get', 'explain_level').stdout).toBe('terse');
|
|
});
|
|
|
|
test('unknown value warns and defaults to default', () => {
|
|
const result = run('set', 'explain_level', 'garbage');
|
|
expect(result.status).toBe(0);
|
|
expect(result.stderr).toContain('not recognized');
|
|
expect(result.stderr).toContain('default, terse');
|
|
expect(run('get', 'explain_level').stdout).toBe('default');
|
|
});
|
|
|
|
test('get with unset explain_level returns empty (preamble default takes over)', () => {
|
|
// No prior set → no config file → empty output
|
|
expect(run('get', 'explain_level').stdout).toBe('');
|
|
});
|
|
|
|
test('config header documents explain_level', () => {
|
|
// Trigger file creation with any set
|
|
run('set', 'explain_level', 'default');
|
|
const cfg = fs.readFileSync(path.join(tmpHome, 'config.yaml'), 'utf-8');
|
|
expect(cfg).toContain('explain_level');
|
|
expect(cfg).toContain('default');
|
|
expect(cfg).toContain('terse');
|
|
});
|
|
|
|
test('set terse, then set garbage restores default', () => {
|
|
run('set', 'explain_level', 'terse');
|
|
expect(run('get', 'explain_level').stdout).toBe('terse');
|
|
const garbage = run('set', 'explain_level', 'nonsense');
|
|
expect(garbage.stderr).toContain('not recognized');
|
|
expect(run('get', 'explain_level').stdout).toBe('default');
|
|
});
|
|
});
|