From a8462eb27ceb6de21016aea5da285e769ddaf3b1 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Thu, 22 Oct 2026 12:18:28 -0700 Subject: [PATCH] test: stabilize CLI adapter timing fixtures Co-authored-by: CI Doctor Agent-Model: codex/gpt-6-sol/medium --- cli/__tests__/adapters.claude.test.mjs | 7 ++----- cli/__tests__/adapters.opencode.test.mjs | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/__tests__/adapters.claude.test.mjs b/cli/__tests__/adapters.claude.test.mjs index 0010db47b4..5cebc89cea 100644 --- a/cli/__tests__/adapters.claude.test.mjs +++ b/cli/__tests__/adapters.claude.test.mjs @@ -255,17 +255,14 @@ describe('claude adapter — spawn()', () => { }); test('rejects on timeout and SIGTERMs the child', async () => { - // Child never emits close within the window. + // Child closes only after the timeout kills it, independent of host load. const proc = new EventEmitter(); proc.stdout = new EventEmitter(); proc.stderr = new EventEmitter(); - proc.kill = jest.fn(); + proc.kill = jest.fn(() => queueMicrotask(() => proc.emit('close', null))); const impl = () => proc; const p = claude.spawn('x', { sessionId: 'sid-1', timeoutMs: 20, _spawnImpl: impl }); - // After kill, simulate the process closing so the adapter resolves its close handler. - setTimeout(() => proc.emit('close', null), 40); - await expect(p).rejects.toThrow(/timed out after 20ms/); expect(proc.kill).toHaveBeenCalledWith('SIGTERM'); }); diff --git a/cli/__tests__/adapters.opencode.test.mjs b/cli/__tests__/adapters.opencode.test.mjs index 57abedbf89..a651fe6186 100644 --- a/cli/__tests__/adapters.opencode.test.mjs +++ b/cli/__tests__/adapters.opencode.test.mjs @@ -331,6 +331,9 @@ describe('opencode public seat withholds a turn whose Commonly tools failed', () })); await writeFile(join(pkgDir, 'src', 'index.js'), ''); await writeFile(join(home, 'current'), '0.3.13\n'); + // The selected MCP is already installed for this fixture. Keep the + // detached warmer from racing with withTemp's teardown. + await writeFile(join(home, '.warm.lock'), 'warming\n'); const workspace = join(root, 'workspace'); await mkdir(workspace); const keyFile = join(root, 'provider-key');