mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-06 16:24:17 +00:00
test(cli): wait for killed child processes to exit in runner shell tests
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user