import { test, expect } from "bun:test"; import { bunEnv, bunExe, isWindows } from "harness"; test("pipe does the right thing", async () => { // Note: Bun.spawnSync uses memfd_create on Linux for pipe, which means we see // it as a file instead of a tty const result = Bun.spawn({ cmd: [bunExe(), "-e", "console.log(typeof process.stdin.ref)"], stdin: "pipe", stdout: "pipe", stderr: "inherit", env: bunEnv, }); expect((await new Response(result.stdout).text()).trim()).toBe("function"); expect(await result.exited).toBe(0); }); test("file does the right thing", async () => { const result = Bun.spawn({ cmd: [bunExe(), "-e", "console.log(typeof process.stdin.ref)"], stdin: Bun.file(import.meta.path), stdout: "pipe", stderr: "inherit", env: bunEnv, }); expect((await new Response(result.stdout).text()).trim()).toBe("undefined"); expect(await result.exited).toBe(0); });