test: preserve immediate disposal and observe automatic terminal cleanup
This commit is contained in:
1 parent
6becec9502
commit
9f27a45408
2 files changed
+6
-13
No files matched your search
@@ -661,16 +661,8 @@ describe('background sandbox facts', () => {
|
||||
|
||||
it('disposal kills wrapped background jobs (inherited HMR safety)', async () => {
|
||||
const { ctx, bash } = await setup()
|
||||
const task = bash.start(bash.resolve({ command: 'echo ready; sleep 30' }))
|
||||
let output = ''
|
||||
try {
|
||||
await expect.poll(() => {
|
||||
output += task.readOutput().delta
|
||||
return output
|
||||
}).toContain('ready')
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
}
|
||||
const task = bash.start(bash.resolve({ command: 'sleep 30' }))
|
||||
await ctx.fiber.dispose()
|
||||
expect(task.status).toBe('killed')
|
||||
})
|
||||
})
|
||||
@@ -400,8 +400,7 @@ describe('LocalSubprocessRuntime', () => {
|
||||
expect((service as unknown as { terminals: Set<SubprocessTerminalHandle> }).terminals.size).toBe(1)
|
||||
exitListener?.({ exitCode: 0 })
|
||||
await handle.done
|
||||
await new Promise(resolve => setImmediate(resolve))
|
||||
expect((service as unknown as { terminals: Set<SubprocessTerminalHandle> }).terminals.size).toBe(0)
|
||||
await expect.poll(() => (service as unknown as { terminals: Set<SubprocessTerminalHandle> }).terminals.size).toBe(0)
|
||||
await fiber.dispose()
|
||||
} finally {
|
||||
vi.doUnmock('node-pty')
|
||||
@@ -617,9 +616,11 @@ describe('LocalSubprocessRuntime', () => {
|
||||
const handle = await ctx.subprocess.spawnTerminal({
|
||||
argv: ['shell'], cwd: process.cwd(), rows: 24, cols: 80, graceMs: 1,
|
||||
})
|
||||
const terminate = vi.spyOn(handle, 'terminate')
|
||||
exitListener?.({ exitCode: 0 })
|
||||
await handle.done
|
||||
await expect(handle.terminate()).rejects.toThrow('surviving pids: 124')
|
||||
await expect.poll(() => terminate.mock.calls.length).toBe(1)
|
||||
await expect(terminate.mock.results[0]?.value).rejects.toThrow('surviving pids: 124')
|
||||
expect((ctx.subprocess as unknown as { terminals: Set<SubprocessTerminalHandle> }).terminals.size).toBe(1)
|
||||
await fiber.dispose()
|
||||
expect(disposalErrors).toHaveLength(1)
|
||||
|
||||
Reference in new issue
Block a user