aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-01 17:38:19 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-01 17:38:19 -0700
commitaf46a8ded1be0af1a1f4f638122ca6d0d7b62405 (patch)
treeb23763db1bd27ac347e70934ecc7875d9cad2647
parentf00e2be548da21b9feaef178bb0ac22230801d6f (diff)
downloadbun-af46a8ded1be0af1a1f4f638122ca6d0d7b62405.tar.gz
bun-af46a8ded1be0af1a1f4f638122ca6d0d7b62405.tar.zst
bun-af46a8ded1be0af1a1f4f638122ca6d0d7b62405.zip
Make this test less flaky
-rw-r--r--test/js/bun/spawn/spawn-streaming-stdin.test.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/js/bun/spawn/spawn-streaming-stdin.test.ts b/test/js/bun/spawn/spawn-streaming-stdin.test.ts
index 27efa14ec..0c430b680 100644
--- a/test/js/bun/spawn/spawn-streaming-stdin.test.ts
+++ b/test/js/bun/spawn/spawn-streaming-stdin.test.ts
@@ -2,18 +2,22 @@ import { it, test, expect } from "bun:test";
import { spawn } from "bun";
import { bunExe, bunEnv, gcTick } from "harness";
import { closeSync, openSync } from "fs";
+import { tmpdir } from "node:os";
+import { join } from "path";
+import { unlinkSync } from "node: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++) {
+ const tmperr = join(tmpdir(), "stdin-repro-error.log." + 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"),
+ stderr: Bun.file(tmperr),
env: bunEnv,
});
exited = proc.exited;
@@ -45,6 +49,10 @@ test("spawn can write to stdin multiple chunks", async () => {
await Promise.all([prom, prom2]);
expect(Buffer.concat(chunks).toString().trim()).toBe("Wrote to stdin!\n".repeat(4).trim());
await proc.exited;
+
+ try {
+ unlinkSync(tmperr);
+ } catch (e) {}
})();
}
@@ -54,4 +62,4 @@ test("spawn can write to stdin multiple chunks", async () => {
// assert we didn't leak any file descriptors
expect(newMaxFD).toBe(maxFD);
-});
+}, 10_000);