| 61 | }) |
| 62 | |
| 63 | const runOpenSelect = (input: string, customQuit = false) => |
| 64 | Effect.callback<{ stdout: string; stderr: string }>((resume) => { |
| 65 | const child = spawn(process.execPath, [fixture, customQuit ? "select-custom-quit" : "select"]) |
| 66 | let stdout = "" |
| 67 | let stderr = "" |
| 68 | let submitted = false |
| 69 | child.stdout.setEncoding("utf8") |
| 70 | child.stderr.setEncoding("utf8") |
| 71 | child.stdout.on("data", (data) => { |
| 72 | stdout += data |
| 73 | // Wait for bare Esc to be decoded before submitting the custom prompt. |
| 74 | if (customQuit && !submitted && stdout.includes("\x07")) { |
| 75 | submitted = true |
| 76 | child.stdin.write("\r") |
| 77 | } |
| 78 | }) |
| 79 | child.stderr.on("data", (data) => { |
| 80 | stderr += data |
| 81 | if (stderr.includes("RESULT ")) { |
| 82 | child.stdin.end() |
| 83 | } |
| 84 | }) |
| 85 | child.on("error", (error) => resume(Effect.die(error))) |
| 86 | child.on("close", (code) => { |
| 87 | resume(code === 0 ? Effect.succeed({ stdout, stderr }) : Effect.die(new Error(stderr))) |
| 88 | }) |
| 89 | child.stdin.write(input) |
| 90 | return Effect.sync(() => child.kill()) |
| 91 | }) |
| 92 | |
| 93 | // spawnSync blocks the Vitest worker; concurrent tests share a running timeout |
| 94 | // while waiting for other fixture processes to finish. |