Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test: add tsconfig depth limit and cleanupAliases exception tests

Affaan Mustafaa4848da38b03
diff --git a/tests/hooks/hooks.test.js b/tests/hooks/hooks.test.js
index f0dd118c4..5933bff81 100644
--- a/tests/hooks/hooks.test.js
+++ b/tests/hooks/hooks.test.js
@@ -618,6 +618,27 @@ async function runTests() {
cleanupTestDir(testDir);
})) 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
console.log('\nsession-end.js (extractSessionSummary):');
diff --git a/tests/lib/session-aliases.test.js b/tests/lib/session-aliases.test.js
index fa955132b..b8dc2cd4c 100644
--- a/tests/lib/session-aliases.test.js
+++ b/tests/lib/session-aliases.test.js
@@ -402,6 +402,27 @@ function runTests() {
assert.ok(result.error);
})) 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
console.log('\nlistAliases (edge cases):');