|
|
@@ -322,6 +322,32 @@ describe('LocalBashExecutor.start (background process handles)', () => {
|
|
|
expect(proc.readOutput().delta).toBe('')
|
|
|
})
|
|
|
|
|
|
+ it('settles an unprintable provider rejection instead of rejecting done', async () => {
|
|
|
+ const { ctx, bash } = await setup()
|
|
|
+ const emptyReader: SubprocessOutputReader = {
|
|
|
+ readFrom: () => ({ text: '', nextOffset: 0, lossy: false }),
|
|
|
+ }
|
|
|
+ const providerError = new Error('unprintable provider error')
|
|
|
+ Object.defineProperty(providerError, Symbol.toPrimitive, {
|
|
|
+ value: () => { throw new Error('provider formatting must not escape') },
|
|
|
+ })
|
|
|
+ vi.spyOn(ctx.subprocess, 'spawn').mockReturnValue({
|
|
|
+ stdin: undefined,
|
|
|
+ stdout: undefined,
|
|
|
+ stderr: undefined,
|
|
|
+ collected: { stdout: emptyReader, stderr: emptyReader },
|
|
|
+ done: Promise.reject(providerError),
|
|
|
+ terminate: vi.fn(),
|
|
|
+ waitForExit: async () => true,
|
|
|
+ } satisfies SubprocessHandle)
|
|
|
+
|
|
|
+ const proc = bash.start(bash.resolve({ command: 'true' }))
|
|
|
+ await expect(proc.done).resolves.toBeUndefined()
|
|
|
+ expect(proc.status).toBe('killed')
|
|
|
+ expect(proc.readOutput().delta).toContain('unprintable provider failure')
|
|
|
+ expect(proc.readOutput().delta).toBe('')
|
|
|
+ })
|
|
|
+
|
|
|
it('an asynchronous creation failure settles as killed with a stage-neutral note', async () => {
|
|
|
const { bash } = await setup()
|
|
|
const proc = bash.start(bash.resolve({ command: 'true', workdir: '/nonexistent-dsh' }))
|