diff options
author | 2022-11-11 16:02:35 -0800 | |
---|---|---|
committer | 2022-11-11 16:02:35 -0800 | |
commit | 514f2a8eddf1a1d35a33cc096ed7403a79afe36f (patch) | |
tree | 0172fc957c2517381a591420c1467d65fc08efaa /test/bun.js | |
parent | 5f5d74c534c6482d91c07037cd0a1ae02bd92a3f (diff) | |
download | bun-514f2a8eddf1a1d35a33cc096ed7403a79afe36f.tar.gz bun-514f2a8eddf1a1d35a33cc096ed7403a79afe36f.tar.zst bun-514f2a8eddf1a1d35a33cc096ed7403a79afe36f.zip |
Add test that fails on linux
Diffstat (limited to '')
-rw-r--r-- | test/bun.js/bunExe.ts | 7 | ||||
-rw-r--r-- | test/bun.js/spawn-streaming-stdout-repro.js | 3 | ||||
-rw-r--r-- | test/bun.js/spawn-streaming-stdout.test.ts | 25 |
3 files changed, 35 insertions, 0 deletions
diff --git a/test/bun.js/bunExe.ts b/test/bun.js/bunExe.ts new file mode 100644 index 000000000..2f1a89cd2 --- /dev/null +++ b/test/bun.js/bunExe.ts @@ -0,0 +1,7 @@ +export function bunExe() { + if (Bun.version.includes("debug")) { + return "bun-debug"; + } + + return "bun"; +} diff --git a/test/bun.js/spawn-streaming-stdout-repro.js b/test/bun.js/spawn-streaming-stdout-repro.js new file mode 100644 index 000000000..7279574bf --- /dev/null +++ b/test/bun.js/spawn-streaming-stdout-repro.js @@ -0,0 +1,3 @@ +setInterval(() => { + console.log("Wrote to stdout"); +}, 20); diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/bun.js/spawn-streaming-stdout.test.ts new file mode 100644 index 000000000..88c028db3 --- /dev/null +++ b/test/bun.js/spawn-streaming-stdout.test.ts @@ -0,0 +1,25 @@ +import { it, test, expect } from "bun:test"; +import { spawn } from "bun"; +import { bunExe } from "./bunExe"; + +test("spawn can read from stdout multiple chunks", async () => { + const proc = spawn({ + cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"], + stdout: "pipe", + env: { + BUN_DEBUG_QUIET_LOGS: 1, + }, + }); + + var counter = 0; + for await (var chunk of proc.stdout) { + expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n"); + counter++; + + if (counter > 3) break; + } + + expect(counter).toBe(4); + proc.kill(); + await proc.exited; +}); |