mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
fix(e2e): honor kitchen sink output caps
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user