mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
31 lines
926 B
TypeScript
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);
|
|
});
|