fix(process): preserve UTF-8 at diagnostic truncation boundaries (#8907)

* fix(process): preserve UTF-8 at diagnostic truncation boundaries

* fix(process): preserve malformed UTF-8 excerpt evidence
This commit is contained in:
Afloat authored and GitHub committed 2026-11-06 10:13:14 +08:00
1 parent a3621e5e1f
commit 3eff8065e7
3 files changed
+156 -3

No files matched your search

+16
View File
@@ -3,6 +3,22 @@ import { describe, expect, it } from "vitest";
import { execFileBoundedOutput } from "./ExecFileBoundedOutput.js";
describe("execFileBoundedOutput", () => {
it("retains complete UTF-8 characters at both sides of truncated command output", async () => {
const text = `A🙂${"x".repeat(30)}🙂Z`;
const result = await execFileBoundedOutput(
process.execPath,
[
"-e",
`process.stdout.write(${JSON.stringify(text)}); process.stderr.write(${JSON.stringify(text)});`,
],
{ env: {}, limit: 8 },
);
expect(result.exitCode).toBe(0);
expect(result.stdout).toBe("A … [output omitted] … Z");
expect(result.stderr).toBe("A … [output omitted] … Z");
expect(result.outputTruncated).toBe(true);
});
it("lets a command finish after its output exceeds the capture limit", async () => {
const result = await execFileBoundedOutput(
process.execPath,