fix(e2e): honor kitchen sink output caps

This commit is contained in:
Vincent Koc
2026-06-07 04:26:55 +02:00
parent 4911615e72
commit c40d2c45bf
2 changed files with 19 additions and 2 deletions
+4 -2
View File
@@ -245,6 +245,7 @@ export function runCommand(command, args, options = {}) {
resourceSampleIntervalMs = 1000,
resourceSampleOptions,
resourceSamples,
outputCaptureChars = config.outputCaptureChars,
requireResourceSample = false,
sampleProcessImpl = sampleProcess,
timeoutKillGraceMs = 2000,
@@ -318,10 +319,10 @@ export function runCommand(command, args, options = {}) {
forceKillTimer.unref();
}, timeoutMs);
child.stdout?.on("data", (chunk) => {
stdout = appendBoundedOutput(stdout, chunk);
stdout = appendBoundedOutput(stdout, chunk, outputCaptureChars);
});
child.stderr?.on("data", (chunk) => {
stderr = appendBoundedOutput(stderr, chunk);
stderr = appendBoundedOutput(stderr, chunk, outputCaptureChars);
});
child.on("error", (error) => {
clearTimeout(timer);
@@ -395,6 +396,7 @@ async function runOpenClaw(runner, args, env, options = {}) {
resourceSampleIntervalMs: options.resourceSampleIntervalMs,
resourceSampleOptions: options.resourceSampleOptions,
resourceSamples: options.resourceSamples,
outputCaptureChars: config.outputCaptureChars,
requireResourceSample: options.requireResourceSample,
timeoutMs: options.timeoutMs ?? config.commandTimeoutMs,
});
@@ -462,6 +462,21 @@ describe("kitchen-sink RPC command output capture", () => {
expect(second).toEqual({ text: "fghij", truncatedChars: 5 });
});
it("honors the resolved command output capture limit", async () => {
const result = await runCommand(
process.execPath,
["-e", "process.stdout.write('abcdef'); process.stderr.write('UVWXYZ');"],
{
outputCaptureChars: 3,
},
);
expect(result.stdout).toBe("def");
expect(result.stderr).toBe("XYZ");
expect(result.stdoutTruncatedChars).toBe(3);
expect(result.stderrTruncatedChars).toBe(3);
});
posixIt("kills timed command process groups", async () => {
const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-timeout-"));
const scriptPath = path.join(root, "trap-term.mjs");