blob: 1f736533a40bc325aeef7dae49bae9c328230fb5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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);
});
|