| 20 | } |
| 21 | |
| 22 | const assertOpenResult = (mode: string, input: string, expected: string) => |
| 23 | Effect.callback<void>((resume) => { |
| 24 | const child = spawn(Deno.execPath(), [fixture, mode]) |
| 25 | let stderr = "" |
| 26 | child.stderr.setEncoding("utf8") |
| 27 | child.stderr.on("data", (data) => { |
| 28 | stderr += data |
| 29 | if (stderr.includes("RESULT ")) { |
| 30 | child.stdin.end() |
| 31 | } |
| 32 | }) |
| 33 | child.on("exit", (code) => { |
| 34 | resume( |
| 35 | code === 0 && stderr.includes(`RESULT ${expected}`) |
| 36 | ? Effect.void |
| 37 | : Effect.die(new Error(stderr)) |
| 38 | ) |
| 39 | }) |
| 40 | child.stdin.write(input) |
| 41 | return Effect.sync(() => child.kill()) |
| 42 | }) |
| 43 | |
| 44 | const assertInteropResult = Effect.callback<void>((resume) => { |
| 45 | const child = spawn(Deno.execPath(), [fixture, "interop"]) |