| 189 | |
| 190 | it('runs a shell command via the Bash tool and records its output', async () => { |
| 191 | const fakeProcess = (stdout: string): KaosProcess => { |
| 192 | const out = Readable.from([stdout]); |
| 193 | const err = Readable.from([]); |
| 194 | return { |
| 195 | stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable, |
| 196 | stdout: out, |
| 197 | stderr: err, |
| 198 | pid: 1, |
| 199 | exitCode: 0, |
| 200 | wait: vi.fn(async () => 0), |
| 201 | kill: vi.fn(async () => {}), |
| 202 | dispose: vi.fn(async () => { |
| 203 | out.destroy(); |
| 204 | err.destroy(); |
| 205 | }), |
| 206 | }; |
| 207 | }; |
| 208 | const kaos = createFakeKaos({ |
| 209 | execWithEnv: vi.fn().mockImplementation(async () => fakeProcess('hello\n')), |
| 210 | }); |