aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/spawn-streaming-stdin.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/spawn-streaming-stdin.test.ts')
-rw-r--r--test/bun.js/spawn-streaming-stdin.test.ts59
1 files changed, 0 insertions, 59 deletions
diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/bun.js/spawn-streaming-stdin.test.ts
deleted file mode 100644
index 02067b719..000000000
--- a/test/bun.js/spawn-streaming-stdin.test.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { it, test, expect } from "bun:test";
-import { spawn } from "bun";
-import { bunExe } from "./bunExe";
-import { gcTick } from "gc";
-import { closeSync, openSync } from "fs";
-import { bunEnv } from "./bunEnv";
-
-const N = 100;
-test("spawn can write to stdin multiple chunks", async () => {
- const maxFD = openSync("/dev/null", "w");
- for (let i = 0; i < N; i++) {
- var exited;
- await (async function () {
- const proc = spawn({
- cmd: [bunExe(), import.meta.dir + "/stdin-repro.js"],
- stdout: "pipe",
- stdin: "pipe",
- stderr: Bun.file("/tmp/out.log"),
- env: bunEnv,
- });
- exited = proc.exited;
- var counter = 0;
- var inCounter = 0;
- var chunks = [];
- const prom = (async function () {
- try {
- for await (var chunk of proc.stdout) {
- chunks.push(chunk);
- }
- } catch (e) {
- console.log(e.stack);
- throw e;
- }
- })();
-
- const prom2 = (async function () {
- while (true) {
- proc.stdin.write("Wrote to stdin!\n");
- inCounter++;
- await new Promise(resolve => setTimeout(resolve, 8));
-
- if (inCounter === 4) break;
- }
- proc.stdin.end();
- })();
-
- await Promise.all([prom, prom2]);
- expect(Buffer.concat(chunks).toString().trim()).toBe("Wrote to stdin!\n".repeat(4).trim());
- await proc.exited;
- })();
- }
-
- closeSync(maxFD);
- const newMaxFD = openSync("/dev/null", "w");
- closeSync(newMaxFD);
-
- // assert we didn't leak any file descriptors
- expect(newMaxFD).toBe(maxFD);
-});