diff --git a/packages/opencode/test/effect/cross-spawn-spawner.test.ts b/packages/opencode/test/effect/cross-spawn-spawner.test.ts index 7fdcb61cd4..6da0715212 100644 --- a/packages/opencode/test/effect/cross-spawn-spawner.test.ts +++ b/packages/opencode/test/effect/cross-spawn-spawner.test.ts @@ -351,122 +351,8 @@ describe("cross-spawn spawner", () => { }), ) - fx.effect( - "pipes output fd3 with { from: 'fd3' }", - Effect.gen(function* () { - const handle = yield* js('require("node:fs").writeSync(3, "hello from fd3\\n")', { - additionalFds: { fd3: { type: "output" } }, - }).pipe( - ChildProcess.pipeTo( - js( - 'process.stdin.setEncoding("utf8"); let out = ""; process.stdin.on("data", (chunk) => out += chunk); process.stdin.on("end", () => process.stdout.write(out))', - ), - { from: "fd3" }, - ), - ) - const out = yield* decodeByteStream(handle.stdout) - yield* handle.exitCode - expect(out).toBe("hello from fd3") - }), - ) - - fx.effect( - "pipes stdout to fd3", - Effect.gen(function* () { - if (process.platform === "win32") return - - const handle = yield* js('process.stdout.write("hello from stdout")').pipe( - ChildProcess.pipeTo(js('process.stdout.write(require("node:fs").readFileSync(3, "utf8"))'), { to: "fd3" }), - ) - const out = yield* decodeByteStream(handle.stdout) - yield* handle.exitCode - expect(out).toBe("hello from stdout") - }), - ) }) - describe("additional fds", () => { - fx.effect( - "reads data from output fd3", - Effect.gen(function* () { - const handle = yield* js('require("node:fs").writeSync(3, "hello from fd3\\n")', { - additionalFds: { fd3: { type: "output" } }, - }) - const out = yield* decodeByteStream(handle.getOutputFd(3)) - yield* handle.exitCode - expect(out).toBe("hello from fd3") - }), - ) - - fx.effect( - "writes data to input fd3", - Effect.gen(function* () { - if (process.platform === "win32") return - - const input = Stream.make(new TextEncoder().encode("data from parent")) - const handle = yield* js('process.stdout.write(require("node:fs").readFileSync(3, "utf8"))', { - additionalFds: { fd3: { type: "input", stream: input } }, - }) - const out = yield* decodeByteStream(handle.stdout) - yield* handle.exitCode - expect(out).toBe("data from parent") - }), - ) - - fx.effect( - "returns empty stream for unconfigured fd", - Effect.gen(function* () { - const handle = - process.platform === "win32" - ? yield* js('process.stdout.write("test")') - : yield* ChildProcess.make("echo", ["test"]) - const out = yield* decodeByteStream(handle.getOutputFd(3)) - yield* handle.exitCode - expect(out).toBe("") - }), - ) - - fx.effect( - "works alongside normal stdout and stderr", - Effect.gen(function* () { - const handle = yield* js( - 'require("node:fs").writeSync(3, "fd3\\n"); process.stdout.write("stdout\\n"); process.stderr.write("stderr\\n")', - { - additionalFds: { fd3: { type: "output" } }, - }, - ) - const stdout = yield* decodeByteStream(handle.stdout) - const stderr = yield* decodeByteStream(handle.stderr) - const fd3 = yield* decodeByteStream(handle.getOutputFd(3)) - yield* handle.exitCode - expect(stdout).toBe("stdout") - expect(stderr).toBe("stderr") - expect(fd3).toBe("fd3") - }), - ) - }) - - describe("large output", () => { - fx.effect( - "does not deadlock on large stdout", - Effect.gen(function* () { - const handle = yield* js("for (let i = 1; i <= 100000; i++) process.stdout.write(`${i}\\n`)") - const out = yield* handle.stdout.pipe( - Stream.decodeText(), - Stream.runFold( - () => "", - (acc, chunk) => acc + chunk, - ), - ) - yield* handle.exitCode - const lines = out.trim().split("\n") - expect(lines.length).toBe(100000) - expect(lines[0]).toBe("1") - expect(lines[99999]).toBe("100000") - }), - { timeout: 10_000 }, - ) - }) describe("Windows-specific", () => { fx.effect(