mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 02:52:15 +00:00
fix(e2e): bound kitchen sink failure logs
This commit is contained in:
@@ -14,6 +14,10 @@ const LOG_SCAN_MAX_FILES = 5000;
|
||||
const LOG_SCAN_MAX_FINDINGS = 100;
|
||||
const LOG_SCAN_MAX_LINE_CHARS = 16 * 1024;
|
||||
const LOG_SCAN_SEGMENT_OVERLAP_CHARS = 256;
|
||||
const EXPECT_FAILURE_OUTPUT_MAX_BYTES = readPositiveIntEnv(
|
||||
"KITCHEN_SINK_EXPECT_FAILURE_OUTPUT_MAX_BYTES",
|
||||
1024 * 1024,
|
||||
);
|
||||
|
||||
const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
|
||||
const scratchFile = (name) => path.join(scratchRoot, name);
|
||||
@@ -45,9 +49,21 @@ function resolveHomePath(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function readTextFileBounded(file, maxBytes, label) {
|
||||
const stats = fs.statSync(file);
|
||||
if (stats.size > maxBytes) {
|
||||
throw new Error(`${label} exceeded ${maxBytes} bytes: ${file} (${stats.size} bytes)`);
|
||||
}
|
||||
return fs.readFileSync(file, "utf8");
|
||||
}
|
||||
|
||||
function expectFailure() {
|
||||
const outputFile = process.argv[3];
|
||||
const output = fs.readFileSync(outputFile, "utf8");
|
||||
const output = readTextFileBounded(
|
||||
outputFile,
|
||||
EXPECT_FAILURE_OUTPUT_MAX_BYTES,
|
||||
"expected failure output",
|
||||
);
|
||||
const source = process.env.KITCHEN_SINK_SOURCE;
|
||||
const spec = process.env.KITCHEN_SINK_SPEC;
|
||||
const displayedSpec = source === "npm" ? spec.replace(/^npm:/u, "") : spec;
|
||||
|
||||
@@ -222,6 +222,33 @@ function runSweepShell(script: string, env: NodeJS.ProcessEnv = {}) {
|
||||
}
|
||||
|
||||
describe("kitchen-sink plugin assertions", () => {
|
||||
it("bounds expected-failure output before matching failure diagnostics", () => {
|
||||
const scratchRoot = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-sink-failure-cap-"));
|
||||
const outputPath = path.join(scratchRoot, "expected-failure.log");
|
||||
try {
|
||||
writeFileSync(outputPath, "x".repeat(128));
|
||||
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
[ASSERTIONS_SCRIPT, "expect-failure", outputPath],
|
||||
{
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
KITCHEN_SINK_EXPECT_FAILURE_OUTPUT_MAX_BYTES: "64",
|
||||
KITCHEN_SINK_SOURCE: "npm",
|
||||
KITCHEN_SINK_SPEC: "npm:@openclaw/kitchen-sink@0.0.0",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status).not.toBe(0);
|
||||
expect(result.stderr).toContain("expected failure output exceeded 64 bytes");
|
||||
} finally {
|
||||
rmSync(scratchRoot, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("fails full-surface installs when stable diagnostic canaries disappear", () => {
|
||||
const result = runAssertInstalled();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user