Skip to content

Commit efd490a

Browse files
JuliusBrusseeclaude
andcommitted
test: fix caveman-init counts, isolate openclaw ws
Counts were stale after the opencode + openclaw targets landed (5 -> 6 repo files, 7 with the openclaw line). Tests also ran the openclaw installer against the developer's real ~/.openclaw/workspace; runInit() now pins OPENCLAW_WORKSPACE inside the fixture tmp dir so nothing escapes the sandbox. verify_repo.py drops the removed .agents/plugins/marketplace.json from its manifest list. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent eb447da commit efd490a

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

tests/test_caveman_init.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ const INIT = path.join(ROOT, 'src', 'tools', 'caveman-init.js');
1414
let passed = 0;
1515
let failed = 0;
1616

17+
// Point OPENCLAW_WORKSPACE at a nonexistent dir inside the fixture so the
18+
// openclaw target reports skipped-workspace-missing instead of writing to
19+
// the developer's real ~/.openclaw/workspace.
20+
function runInit(tmp, ...args) {
21+
return execFileSync(process.execPath, [INIT, tmp, ...args], {
22+
encoding: 'utf8',
23+
env: { ...process.env, OPENCLAW_WORKSPACE: path.join(tmp, 'no-openclaw') },
24+
});
25+
}
26+
1727
function test(name, fn) {
1828
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'caveman-init-test-'));
1929
try {
@@ -31,7 +41,7 @@ function test(name, fn) {
3141
console.log('caveman-init tests\n');
3242

3343
test('greenfield: creates all rule files with proper frontmatter', (tmp) => {
34-
execFileSync(process.execPath, [INIT, tmp], { encoding: 'utf8' });
44+
runInit(tmp);
3545
const cursor = fs.readFileSync(path.join(tmp, '.cursor/rules/caveman.mdc'), 'utf8');
3646
assert.match(cursor, /alwaysApply: true/);
3747
assert.match(cursor, /Respond terse like smart caveman/);
@@ -43,18 +53,21 @@ test('greenfield: creates all rule files with proper frontmatter', (tmp) => {
4353
assert.match(copilot, /Respond terse/);
4454
const agents = fs.readFileSync(path.join(tmp, 'AGENTS.md'), 'utf8');
4555
assert.match(agents, /Respond terse/);
56+
const opencode = fs.readFileSync(path.join(tmp, '.opencode/AGENTS.md'), 'utf8');
57+
assert.match(opencode, /Respond terse/);
4658
});
4759

4860
test('idempotent: re-running on a clean install skips all', (tmp) => {
49-
execFileSync(process.execPath, [INIT, tmp], { encoding: 'utf8' });
50-
const out = execFileSync(process.execPath, [INIT, tmp], { encoding: 'utf8' });
51-
assert.match(out, /5 skipped/);
61+
runInit(tmp);
62+
const out = runInit(tmp);
63+
// 6 repo rule files skipped-already-installed + openclaw skipped (no workspace)
64+
assert.match(out, /7 skipped/);
5265
assert.doesNotMatch(out, /[1-9]\d* added/);
5366
});
5467

5568
test('append mode: existing AGENTS.md gets caveman appended (not replaced)', (tmp) => {
5669
fs.writeFileSync(path.join(tmp, 'AGENTS.md'), '# My project\n\nDo not delete me.\n');
57-
execFileSync(process.execPath, [INIT, tmp], { encoding: 'utf8' });
70+
runInit(tmp);
5871
const agents = fs.readFileSync(path.join(tmp, 'AGENTS.md'), 'utf8');
5972
assert.match(agents, /Do not delete me/);
6073
assert.match(agents, /Respond terse like smart caveman/);
@@ -64,7 +77,7 @@ test('skip mode: existing .cursor rule is not overwritten without --force', (tmp
6477
const dir = path.join(tmp, '.cursor/rules');
6578
fs.mkdirSync(dir, { recursive: true });
6679
fs.writeFileSync(path.join(dir, 'caveman.mdc'), '# original\nDo not delete me.\n');
67-
const out = execFileSync(process.execPath, [INIT, tmp], { encoding: 'utf8' });
80+
const out = runInit(tmp);
6881
assert.match(out, /\? .*\.cursor\/rules\/caveman\.mdc/);
6982
const after = fs.readFileSync(path.join(dir, 'caveman.mdc'), 'utf8');
7083
assert.strictEqual(after, '# original\nDo not delete me.\n');
@@ -74,25 +87,26 @@ test('--force overwrites existing rule files', (tmp) => {
7487
const dir = path.join(tmp, '.cursor/rules');
7588
fs.mkdirSync(dir, { recursive: true });
7689
fs.writeFileSync(path.join(dir, 'caveman.mdc'), '# original\n');
77-
execFileSync(process.execPath, [INIT, tmp, '--force'], { encoding: 'utf8' });
90+
runInit(tmp, '--force');
7891
const after = fs.readFileSync(path.join(dir, 'caveman.mdc'), 'utf8');
7992
assert.match(after, /alwaysApply: true/);
8093
assert.match(after, /Respond terse/);
8194
});
8295

8396
test('--dry-run: announces but writes nothing', (tmp) => {
84-
const out = execFileSync(process.execPath, [INIT, tmp, '--dry-run'], { encoding: 'utf8' });
97+
const out = runInit(tmp, '--dry-run');
8598
assert.match(out, /\(dry run\)/);
86-
assert.match(out, /5 added/);
99+
assert.match(out, /6 added/);
87100
assert.ok(!fs.existsSync(path.join(tmp, '.cursor')));
88101
assert.ok(!fs.existsSync(path.join(tmp, '.windsurf')));
89102
assert.ok(!fs.existsSync(path.join(tmp, '.clinerules')));
90103
assert.ok(!fs.existsSync(path.join(tmp, '.github/copilot-instructions.md')));
104+
assert.ok(!fs.existsSync(path.join(tmp, '.opencode')));
91105
assert.ok(!fs.existsSync(path.join(tmp, 'AGENTS.md')));
92106
});
93107

94108
test('--only filters to one target', (tmp) => {
95-
const out = execFileSync(process.execPath, [INIT, tmp, '--only', 'cline'], { encoding: 'utf8' });
109+
const out = runInit(tmp, '--only', 'cline');
96110
assert.match(out, /1 added/);
97111
assert.ok(fs.existsSync(path.join(tmp, '.clinerules/caveman.md')));
98112
assert.ok(!fs.existsSync(path.join(tmp, '.cursor')));
@@ -104,7 +118,7 @@ test('detects sentinel and skips files that already have caveman content', (tmp)
104118
fs.mkdirSync(dir, { recursive: true });
105119
fs.writeFileSync(path.join(dir, 'caveman.md'),
106120
'# Existing\n\nRespond terse like smart caveman. Hello.\n');
107-
const out = execFileSync(process.execPath, [INIT, tmp, '--only', 'cline'], { encoding: 'utf8' });
121+
const out = runInit(tmp, '--only', 'cline');
108122
assert.match(out, /skipped-already-installed/);
109123
});
110124

tests/verify_repo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def verify_manifests_and_syntax() -> None:
158158
section("Manifests And Syntax")
159159

160160
manifest_paths = [
161-
ROOT / ".agents/plugins/marketplace.json",
162161
ROOT / ".claude-plugin/plugin.json",
163162
ROOT / ".claude-plugin/marketplace.json",
164163
ROOT / ".codex/hooks.json",

0 commit comments

Comments
 (0)