aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/spawn-streaming-stdin.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 00:23:29 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 00:23:29 -0800
commit931ba9ad499838d831d08c8bbac4aa132e8aa0f7 (patch)
tree907ecf5685986588e809c385e66d4973f430bd67 /test/bun.js/spawn-streaming-stdin.test.ts
parent851b8acb762e9a2741a6d03bdf218c6810572f3c (diff)
downloadbun-931ba9ad499838d831d08c8bbac4aa132e8aa0f7.tar.gz
bun-931ba9ad499838d831d08c8bbac4aa132e8aa0f7.tar.zst
bun-931ba9ad499838d831d08c8bbac4aa132e8aa0f7.zip
Add file descriptor leak test
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);
});