mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 16:02:43 +00:00
test(pty): account for asynchronous immediate descendant cleanup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
existsSyncMock,
|
||||
loginPreflightExecFileMock,
|
||||
spawnMock,
|
||||
openCodeClearPtyMock,
|
||||
piClearPtyMock
|
||||
@@ -162,9 +163,25 @@ describe('registerPtyHandlers', () => {
|
||||
rows: 24
|
||||
})) as { id: string }
|
||||
|
||||
let finishSnapshot: (() => void) | undefined
|
||||
loginPreflightExecFileMock.mockImplementationOnce(
|
||||
(
|
||||
_file: string,
|
||||
_args: string[],
|
||||
_options: unknown,
|
||||
callback: (error: Error | null, stdout: string) => void
|
||||
) => {
|
||||
finishSnapshot = () => callback(null, '')
|
||||
}
|
||||
)
|
||||
const killPromise = handlers.get('pty:kill')!(null, { id: spawnResult.id }) as Promise<void>
|
||||
|
||||
expect(killSpy).toHaveBeenCalledTimes(1)
|
||||
expect(killSpy).not.toHaveBeenCalled()
|
||||
expect(onDataDisposable.dispose).not.toHaveBeenCalled()
|
||||
expect(onExitDisposable.dispose).not.toHaveBeenCalled()
|
||||
await vi.waitFor(() => expect(finishSnapshot).toBeTypeOf('function'))
|
||||
finishSnapshot?.()
|
||||
await vi.waitFor(() => expect(killSpy).toHaveBeenCalledTimes(1))
|
||||
expect(onDataDisposable.dispose).not.toHaveBeenCalled()
|
||||
expect(onExitDisposable.dispose).not.toHaveBeenCalled()
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ import { describe, expect, it } from 'vitest'
|
||||
*/
|
||||
const SRC_DIR = join(__dirname, '..')
|
||||
const CALL = 'killWithDescendantSweep('
|
||||
const EXPECTED_MINIMUM_SITES = 5
|
||||
// Local immediate and recognized-agent shutdown share one guarded call site.
|
||||
const EXPECTED_MINIMUM_SITES = 4
|
||||
|
||||
function collectTypeScriptFiles(dir: string): string[] {
|
||||
const found: string[] = []
|
||||
|
||||
Reference in New Issue
Block a user