diff options
author | 2022-11-25 22:53:21 -0800 | |
---|---|---|
committer | 2022-11-25 22:53:21 -0800 | |
commit | 397cb6600b831a1ab5daeac07a5e2d8f113f7c71 (patch) | |
tree | 29e0d43ac03f75c0ddf1ac98a2fdf764c053c902 /test/bun.js/spawn-streaming-stdin.test.ts | |
parent | bef469ea5590bba90c8d10b5bc4610dc4ebdff94 (diff) | |
download | bun-397cb6600b831a1ab5daeac07a5e2d8f113f7c71.tar.gz bun-397cb6600b831a1ab5daeac07a5e2d8f113f7c71.tar.zst bun-397cb6600b831a1ab5daeac07a5e2d8f113f7c71.zip |
Update test
Diffstat (limited to 'test/bun.js/spawn-streaming-stdin.test.ts')
-rw-r--r-- | test/bun.js/spawn-streaming-stdin.test.ts | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/bun.js/spawn-streaming-stdin.test.ts index 6424eadfc..2285c50d2 100644 --- a/test/bun.js/spawn-streaming-stdin.test.ts +++ b/test/bun.js/spawn-streaming-stdin.test.ts @@ -9,7 +9,7 @@ test("spawn can write to stdin multiple chunks", async () => { var exited; await (async function () { const proc = spawn({ - cmd: [bunExe(), import.meta.dir + "/stdin-repro.js"], + cmd: ["bun-debug", import.meta.dir + "/stdin-repro.js"], stdout: "pipe", stdin: "pipe", stderr: Bun.file("/tmp/out.log"), @@ -17,51 +17,40 @@ test("spawn can write to stdin multiple chunks", async () => { BUN_DEBUG_QUIET_LOGS: 1, }, }); - // (async function () { - // for await (var chunk of proc.stderr) { - // console.error("[stderr]", new TextDecoder().decode(chunk)); - // } - // })(); exited = proc.exited; var counter = 0; var inCounter = 0; - const prom2 = (async function () { - while (true) { - await new Promise((resolve, reject) => setTimeout(resolve, 8)); - proc.stdin.write("Wrote to stdin!"); - inCounter++; - - if (inCounter === 4) break; - } - await new Promise((resolve) => - Promise.resolve(proc.stdin.end()).then(resolve), - ); - })(); - var chunks = []; const prom = (async function () { try { for await (var chunk of proc.stdout) { chunks.push(chunk); - counter++; - - if (counter === 4) break; } } catch (e) { console.log(e.stack); throw e; } })(); + + const prom2 = (async function () { + while (true) { + proc.stdin.write("Wrote to stdin!\n"); + inCounter++; + await new Promise((resolve) => setTimeout(resolve, 8)); + + if (inCounter === 4) break; + } + proc.stdin.end(); + })(); + await Promise.all([prom, prom2]); - const code = await exited; - console.log(code); - expect(counter).toBe(4); expect(Buffer.concat(chunks).toString().trim()).toBe( "Wrote to stdin!\n".repeat(4).trim(), ); // proc.kill(); gcTick(true); + await 1; })(); } }); |