The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { assert, describe, it } from "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as PlatformError from "effect/PlatformError"; |
| 4 | import { ChildProcessSpawner } from "effect/process"; |
| 5 | |
| 6 | import * as AcpError from "../errors.ts"; |
| 7 | import { makeTerminationError } from "./stdio.ts"; |
| 8 | |
| 9 | describe("ACP child process termination", () => { |
| 10 | it.effect("retains the process identifier and exact exit-status cause", () => |
| 11 | Effect.gen(function* () { |
| 12 | const rootCause = new Error("private process diagnostics"); |
| 13 | const cause = PlatformError.systemError({ |
| 14 | _tag: "Unknown", |
| 15 | module: "ChildProcess", |
| 16 | method: "exitCode", |
| 17 | cause: rootCause, |
| 18 | }); |
| 19 | const error = yield* makeTerminationError({ |
| 20 | pid: ChildProcessSpawner.ProcessId(42), |
| 21 | exitCode: Effect.fail(cause), |
| 22 | }); |
| 23 | |
| 24 | assert.instanceOf(error, AcpError.AcpTransportError); |
| 25 | assert.equal(error.pid, 42); |
| 26 | assert.strictEqual(error.cause, cause); |
| 27 | assert.equal(error.message, "ACP transport operation read-process-exit-status failed."); |
| 28 | assert.notInclude(error.message, rootCause.message); |
| 29 | }), |
| 30 | ); |
| 31 | }); |