diff --git a/apps/cli/src/runner/shell.test.ts b/apps/cli/src/runner/shell.test.ts index 9af4b71d..6fa70233 100644 --- a/apps/cli/src/runner/shell.test.ts +++ b/apps/cli/src/runner/shell.test.ts @@ -137,13 +137,14 @@ describe('runner bash execution', () => { it('times out and terminates background children', async () => { const result = await shell.run( - { ...request('sleep 30 & echo $!; wait'), timeoutSec: 0.1 }, + { ...request('sleep 30 & echo $!; wait'), timeoutSec: 0.5 }, new AbortController().signal, () => {}, ) expect(result).toMatchObject({ timedOut: true, signal: 'SIGKILL' }) const pid = Number((await readFile(path.join(cwd, '.pi/logs/bash-test.log'), 'utf8')).trim()) - expect(() => process.kill(pid, 0)).toThrow() + expect(pid).toBeGreaterThan(0) + await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow(), { timeout: 2000 }) }) it('cancels a running command and never starts an already cancelled one', async () => { @@ -205,7 +206,7 @@ describe('runner bash execution', () => { ) expect(result.error).toBe('Output consumer failed') expect(pid).toBeGreaterThan(0) - expect(() => process.kill(pid, 0)).toThrow() + await vi.waitFor(() => expect(() => process.kill(pid, 0)).toThrow(), { timeout: 2000 }) }) it('rejects invalid timeouts and caps runaway output', async () => {