Files
rea/src/process/ExecFileOutput.test.ts
T
morluto fc4a9a0592 fix(artifacts): preserve reader failure diagnostics (#987)
* fix(artifacts): preserve filesystem and DMG diagnostics

* fix(artifacts): classify DMG verification failures

* fix(artifacts): distinguish inaccessible disk images

* fix(artifacts): classify damaged image checksums
2026-10-07 23:58:07 +08:00

36 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { execFileOutput } from "./ExecFileOutput.js";
describe("execFileOutput", () => {
it("captures output larger than Node's default execFile limit", async () => {
const marker = "tail-marker";
const result = await execFileOutput(process.execPath, [
"-e",
`process.stdout.write("x".repeat(2 * 1024 * 1024)); process.stdout.write(${JSON.stringify(marker)});`,
]);
expect(result.stdout).toHaveLength(2 * 1024 * 1024 + marker.length);
expect(result.stdout.endsWith(marker)).toBe(true);
});
it("enforces a caller supplied output bound", async () => {
await expect(
execFileOutput(
process.execPath,
["-e", 'process.stdout.write("x".repeat(1024))'],
{ maxBuffer: 64 },
),
).rejects.toMatchObject({ code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" });
});
it("retains both captured streams on a failed child process", async () => {
await expect(
execFileOutput(process.execPath, [
"-e",
'process.stdout.write("out"); process.stderr.write("err"); process.exitCode = 7;',
]),
).rejects.toMatchObject({ code: 7, stdout: "out", stderr: "err" });
});
});