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.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/bun.js/spawn-streaming-stdin.test.ts
index 2285c50d2..a71a0e2a9 100644
--- a/test/bun.js/spawn-streaming-stdin.test.ts
+++ b/test/bun.js/spawn-streaming-stdin.test.ts
@@ -2,9 +2,11 @@ import { it, test, expect } from "bun:test";
import { spawn } from "bun";
import { bunExe } from "./bunExe";
import { gcTick } from "gc";
+import { closeSync, openSync } from "fs";
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 () {
@@ -47,10 +49,14 @@ test("spawn can write to stdin multiple chunks", async () => {
expect(Buffer.concat(chunks).toString().trim()).toBe(
"Wrote to stdin!\n".repeat(4).trim(),
);
- // proc.kill();
-
- gcTick(true);
- await 1;
+ 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);
});