* Run run.ts directly with stdin closed to avoid hanging. * Passes empty stdin to simulate non-TTY invocation without input.
(args: string[], timeoutMs = 5000)
| 84 | * Passes empty stdin to simulate non-TTY invocation without input. |
| 85 | */ |
| 86 | async function runRunDirect(args: string[], timeoutMs = 5000): Promise<ExecResult> { |
| 87 | return new Promise((resolve) => { |
| 88 | const proc = spawn("bun", [RUN_PATH, ...args], { |
| 89 | timeout: timeoutMs, |
| 90 | env: { ...process.env, NO_COLOR: "1" }, |
| 91 | stdio: ["pipe", "pipe", "pipe"], // stdin, stdout, stderr |
| 92 | }); |
| 93 | |
| 94 | let stdout = ""; |
| 95 | let stderr = ""; |
| 96 | |
| 97 | proc.stdout?.on("data", (data: Buffer) => { |
| 98 | stdout += data.toString(); |
| 99 | }); |
| 100 | |
| 101 | proc.stderr?.on("data", (data: Buffer) => { |
| 102 | stderr += data.toString(); |
| 103 | }); |
| 104 | |
| 105 | // Close stdin immediately to prevent hanging on stdin.read() |
| 106 | proc.stdin?.end(); |
| 107 | |
| 108 | proc.on("close", (code) => { |
| 109 | resolve({ stdout, stderr, output: stdout + stderr, exitCode: code ?? 1 }); |
| 110 | }); |
| 111 | |
| 112 | proc.on("error", () => { |
| 113 | resolve({ stdout, stderr, output: stdout + stderr, exitCode: 1 }); |
| 114 | }); |
| 115 | }); |
| 116 | } |
| 117 | |
| 118 | describe("mux CLI", () => { |
| 119 | beforeAll(() => { |
no test coverage detected