aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/bun.js/child-process-stdio.test.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/bun.js/child-process-stdio.test.js b/test/bun.js/child-process-stdio.test.js
index 8542ce588..43bcc771a 100644
--- a/test/bun.js/child-process-stdio.test.js
+++ b/test/bun.js/child-process-stdio.test.js
@@ -1,13 +1,16 @@
import { describe, it, expect, beforeAll } from "bun:test";
import { spawn, execSync } from "node:child_process";
import { bunExe } from "bunExe";
+import { bunEnv } from "bunEnv";
const CHILD_PROCESS_FILE = import.meta.dir + "/spawned-child.js";
const OUT_FILE = import.meta.dir + "/stdio-test-out.txt";
describe("process.stdout", () => {
it("should allow us to write to it", done => {
- const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDOUT"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDOUT"], {
+ env: bunEnv,
+ });
child.stdout.setEncoding("utf8");
child.stdout.on("data", data => {
try {
@@ -24,7 +27,9 @@ describe("process.stdin", () => {
it("should allow us to read from stdin in readable mode", done => {
const input = "hello\n";
// Child should read from stdin and write it back
- const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "READABLE"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "READABLE"], {
+ env: bunEnv,
+ });
let data = "";
child.stdout.setEncoding("utf8");
child.stdout
@@ -46,7 +51,9 @@ describe("process.stdin", () => {
it("should allow us to read from stdin via flowing mode", done => {
const input = "hello\n";
// Child should read from stdin and write it back
- const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"], {
+ env: bunEnv,
+ });
let data = "";
child.stdout.setEncoding("utf8");
child.stdout
@@ -72,7 +79,9 @@ describe("process.stdin", () => {
const numReps = Math.ceil((66 * 1024) / 5);
const input = "hello".repeat(numReps);
// Child should read from stdin and write it back
- const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"], {
+ env: bunEnv,
+ });
let data = "";
child.stdout.setEncoding("utf8");
child.stdout
@@ -97,6 +106,7 @@ describe("process.stdin", () => {
it("should allow us to read from a file", () => {
const result = execSync(`${bunExe()} ${CHILD_PROCESS_FILE} STDIN FLOWING < ${import.meta.dir}/readFileSync.txt`, {
encoding: "utf8",
+ env: bunEnv,
});
expect(result).toEqual("data: File read successfully");
});