Files
reverse-engineering-anything/src/process/ExecFileBoundedOutput.test.ts
T
morluto 599a8ee11d fix(process): preserve cleanup ownership and normalize captures once
Retain unresolved process identity and launch evidence through retryable cleanup. Share capture path normalization and preserve failed filesystem observations. Bound child output and drain Windows pipes without one-chunk throttling.

Reviewed fixes include #1628, #2632, #2644, #2784, #2928, #2931, #2965, #2992, and #3011.

Validation: 92 focused source tests passed; four platform-specific skips. Real Windows and Hopper lifecycle coverage was not rerun.
2026-10-14 08:19:07 +08:00

51 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { execFileBoundedOutput } from "./ExecFileBoundedOutput.js";
describe("execFileBoundedOutput", () => {
it("lets a command finish after its output exceeds the capture limit", async () => {
const result = await execFileBoundedOutput(
process.execPath,
[
"-e",
"process.stdout.write('x'.repeat(70000)); process.stderr.write('failure detail');",
],
{ env: process.env, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(0);
expect(Buffer.byteLength(result.stdout)).toBeLessThan(64 * 1024 + 50);
expect(result.stdout).toContain("[output omitted]");
expect(result.stderr).toBe("failure detail");
expect(result.outputTruncated).toBe(true);
});
it("retains a failing command's status and stderr after verbose stdout", async () => {
const result = await execFileBoundedOutput(
process.execPath,
[
"-e",
"process.stdout.write('x'.repeat(70000)); process.stderr.write('package conflict'); process.exitCode = 1;",
],
{ env: process.env, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(1);
expect(result.stderr).toBe("package conflict");
expect(result.outputTruncated).toBe(true);
});
it("retains a final error after a long prefix in the same stream", async () => {
const result = await execFileBoundedOutput(
process.execPath,
[
"-e",
"process.stderr.write('warning '.repeat(10000)); process.stderr.write('error: final conflict'); process.exitCode = 1;",
],
{ env: process.env, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(1);
expect(result.stderr).toContain("[output omitted]");
expect(result.stderr).toContain("error: final conflict");
expect(result.outputTruncated).toBe(true);
});
});