diff options
author | 2022-11-23 07:14:33 -0800 | |
---|---|---|
committer | 2022-11-23 07:14:33 -0800 | |
commit | ac36ea51cfb85130403ac09299f8e1207bad4bcb (patch) | |
tree | a05bc2d34295bc0087b68b799155f18050451721 /test/bun.js/streams.test.js | |
parent | ae3fcb5bd89a4ac908ba6d4cdb1be4e7c7f0ea81 (diff) | |
download | bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.tar.gz bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.tar.zst bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.zip |
possibly more reliable Bun.spawn (#1547)
* wip
* wip
* Fix bug with stdin
* zig fmt
* seems to work!
* Update streams.test.js
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r-- | test/bun.js/streams.test.js | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/test/bun.js/streams.test.js b/test/bun.js/streams.test.js index bb676041b..a872b7701 100644 --- a/test/bun.js/streams.test.js +++ b/test/bun.js/streams.test.js @@ -218,6 +218,7 @@ it("Bun.file() read text from pipe", async () => { unlinkSync("/tmp/fifo"); } catch (e) {} + console.log("here"); mkfifo("/tmp/fifo", 0o666); // 65k so its less than the max on linux @@ -232,6 +233,8 @@ it("Bun.file() read text from pipe", async () => { "/tmp/fifo", ], stderr: "inherit", + stdout: null, + stdin: null, env: { FIFO_TEST: large, }, @@ -239,32 +242,17 @@ it("Bun.file() read text from pipe", async () => { const exited = proc.exited; proc.ref(); - var prom = new Promise((resolve, reject) => { - setTimeout(() => { - (async function () { - var reader = out.getReader(); - var total = 0; - - while (true) { - const chunk = await reader.read(); - total += chunk.value?.byteLength || 0; - if (chunk.value) chunks.push(chunk.value); - - if (chunk.done || total >= large.length) { - const output = new TextDecoder() - .decode(new Uint8Array(Buffer.concat(chunks))) - .trim(); - reader.releaseLock(); - resolve(output); - break; - } - } - })(); - }); - }); + const prom = (async function () { + while (chunks.length === 0) { + for await (const chunk of out) { + chunks.push(chunk); + } + console.log("done"); + } + })(); const [status, output] = await Promise.all([exited, prom]); - + console.log("here"); expect(output.length).toBe(large.length); expect(output).toBe(large); expect(status).toBe(0); |