mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 18:33:28 +08:00
test: add tsconfig depth limit and cleanupAliases exception tests
- post-edit-typecheck: verify 25-level-deep directory completes without hanging (tests the max depth=20 walk-up guard) - cleanupAliases: document behavior when sessionExists callback throws (propagates to caller, which is acceptable)
This commit is contained in:
@@ -618,6 +618,27 @@ async function runTests() {
|
|||||||
cleanupTestDir(testDir);
|
cleanupTestDir(testDir);
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (await asyncTest('stops tsconfig walk at max depth (20)', async () => {
|
||||||
|
// Create a deeply nested directory (>20 levels) with no tsconfig anywhere
|
||||||
|
const testDir = createTestDir();
|
||||||
|
let deepDir = testDir;
|
||||||
|
for (let i = 0; i < 25; i++) {
|
||||||
|
deepDir = path.join(deepDir, `d${i}`);
|
||||||
|
}
|
||||||
|
fs.mkdirSync(deepDir, { recursive: true });
|
||||||
|
const testFile = path.join(deepDir, 'deep.ts');
|
||||||
|
fs.writeFileSync(testFile, 'const x: number = 1;');
|
||||||
|
|
||||||
|
const stdinJson = JSON.stringify({ tool_input: { file_path: testFile } });
|
||||||
|
const startTime = Date.now();
|
||||||
|
const result = await runScript(path.join(scriptsDir, 'post-edit-typecheck.js'), stdinJson);
|
||||||
|
const elapsed = Date.now() - startTime;
|
||||||
|
|
||||||
|
assert.strictEqual(result.code, 0, 'Should not hang at depth limit');
|
||||||
|
assert.ok(elapsed < 5000, `Should complete quickly at depth limit, took ${elapsed}ms`);
|
||||||
|
cleanupTestDir(testDir);
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
// session-end.js extractSessionSummary tests
|
// session-end.js extractSessionSummary tests
|
||||||
console.log('\nsession-end.js (extractSessionSummary):');
|
console.log('\nsession-end.js (extractSessionSummary):');
|
||||||
|
|
||||||
|
|||||||
@@ -402,6 +402,27 @@ function runTests() {
|
|||||||
assert.ok(result.error);
|
assert.ok(result.error);
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (test('handles sessionExists that throws an exception', () => {
|
||||||
|
resetAliases();
|
||||||
|
aliases.setAlias('bomb', '/path/bomb');
|
||||||
|
aliases.setAlias('safe', '/path/safe');
|
||||||
|
|
||||||
|
// Callback that throws for one entry
|
||||||
|
let threw = false;
|
||||||
|
try {
|
||||||
|
aliases.cleanupAliases((p) => {
|
||||||
|
if (p === '/path/bomb') throw new Error('simulated failure');
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
threw = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Currently cleanupAliases does not catch callback exceptions
|
||||||
|
// This documents the behavior — it throws, which is acceptable
|
||||||
|
assert.ok(threw, 'Should propagate callback exception to caller');
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
// listAliases edge cases
|
// listAliases edge cases
|
||||||
console.log('\nlistAliases (edge cases):');
|
console.log('\nlistAliases (edge cases):');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user