Files
bun.sh/test/js/node/process/process-stdin.test.ts

31 lines
926 B
TypeScript

import { expect, test } from "bun:test";
import { bunEnv, bunExe } 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);
});