diff options
Diffstat (limited to 'test/bun.js/spawn-streaming-stdout.test.ts')
-rw-r--r-- | test/bun.js/spawn-streaming-stdout.test.ts | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/test/bun.js/spawn-streaming-stdout.test.ts b/test/bun.js/spawn-streaming-stdout.test.ts index 1f736533a..1d19fe5da 100644 --- a/test/bun.js/spawn-streaming-stdout.test.ts +++ b/test/bun.js/spawn-streaming-stdout.test.ts @@ -5,37 +5,32 @@ import { gcTick } from "gc"; test("spawn can read from stdout multiple chunks", async () => { gcTick(true); - var exited; - await (async function () { - const proc = spawn({ - cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"], - stdout: "pipe", - env: { - BUN_DEBUG_QUIET_LOGS: 1, - }, - }); - exited = proc.exited; - gcTick(true); - var counter = 0; - try { - for await (var chunk of proc.stdout) { - gcTick(true); - expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n"); - counter++; - if (counter > 3) break; - } - } catch (e) { - console.log(e.stack); - throw e; - } - gcTick(true); + for (let i = 0; i < 10; i++) + await (async function () { + var exited; + const proc = spawn({ + cmd: [bunExe(), import.meta.dir + "/spawn-streaming-stdout-repro.js"], + stdout: "pipe", + stderr: "ignore", + env: { + BUN_DEBUG_QUIET_LOGS: 1, + }, + }); + exited = proc.exited; + let counter = 0; + try { + for await (var chunk of proc.stdout) { + expect(new TextDecoder().decode(chunk)).toBe("Wrote to stdout\n"); + counter++; - expect(counter).toBe(4); - gcTick(); - proc.kill(); - gcTick(); - })(); - await exited; - gcTick(true); + if (counter > 3) break; + } + } catch (e) { + console.log(e.stack); + throw e; + } + expect(counter).toBe(4); + await exited; + })(); }); |