mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
* 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>
42 lines
931 B
TypeScript
42 lines
931 B
TypeScript
import { it, test, expect } from "bun:test";
|
|
import { spawn } from "bun";
|
|
import { bunExe } from "./bunExe";
|
|
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);
|
|
|
|
expect(counter).toBe(4);
|
|
gcTick();
|
|
proc.kill();
|
|
gcTick();
|
|
})();
|
|
await exited;
|
|
gcTick(true);
|
|
});
|