Minimal handle whose process.spawn replays scripted stdout chunks.
(chunks: Array<string>)
| 18 | |
| 19 | /** Minimal handle whose process.spawn replays scripted stdout chunks. */ |
| 20 | function handleSpawning(chunks: Array<string>): SandboxHandle { |
| 21 | const spawnHandle: SpawnHandle = { |
| 22 | pid: 1, |
| 23 | stdout: fromChunks(chunks), |
| 24 | stderr: fromChunks([]), |
| 25 | stdin: { write: () => Promise.resolve(), end: () => Promise.resolve() }, |
| 26 | wait: () => Promise.resolve(0), |
| 27 | kill: () => Promise.resolve(), |
| 28 | } |
| 29 | return { |
| 30 | id: 'fake', |
| 31 | provider: 'fake', |
| 32 | capabilities: { |
| 33 | fs: true, |
| 34 | exec: true, |
| 35 | env: true, |
| 36 | ports: false, |
| 37 | backgroundProcesses: true, |
| 38 | writableStdin: true, |
| 39 | snapshots: false, |
| 40 | networkPolicy: false, |
| 41 | durableFilesystem: false, |
| 42 | fork: false, |
| 43 | }, |
| 44 | // Only process.spawn is exercised here. |
| 45 | fs: {} as SandboxHandle['fs'], |
| 46 | git: {} as SandboxHandle['git'], |
| 47 | process: { |
| 48 | exec: () => Promise.reject(new Error('unused')), |
| 49 | spawn: () => Promise.resolve(spawnHandle), |
| 50 | }, |
| 51 | ports: { connect: () => Promise.reject(new Error('unused')) }, |
| 52 | env: { set: () => Promise.resolve() }, |
| 53 | destroy: () => Promise.resolve(), |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | describe('toLines', () => { |
| 58 | it('reassembles lines split across chunk boundaries', async () => { |
no test coverage detected