mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 01:14:56 +00:00
fix(scripts): bound gateway watch log capture
This commit is contained in:
@@ -4,9 +4,12 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
appendBoundedWatchLog,
|
||||
hasGatewayReadyLog,
|
||||
shouldRefreshBuildStampForRestoredArtifacts,
|
||||
stopTimedWatchChild,
|
||||
updateWatchBuildDetection,
|
||||
WATCH_LOG_CAPTURE_MAX_CHARS,
|
||||
writeBuildAndRuntimePostBuildStamps,
|
||||
} from "../../scripts/check-gateway-watch-regression.mjs";
|
||||
import {
|
||||
@@ -21,6 +24,34 @@ describe("check-gateway-watch-regression", () => {
|
||||
expect(hasGatewayReadyLog("[gateway] starting HTTP server...")).toBe(false);
|
||||
});
|
||||
|
||||
it("bounds in-memory watch output capture while keeping the newest logs", () => {
|
||||
const first = appendBoundedWatchLog("abc", "def", 8);
|
||||
expect(first).toEqual({ text: "abcdef", truncated: false });
|
||||
|
||||
const second = appendBoundedWatchLog(first.text, "ghijkl", 8);
|
||||
expect(second).toEqual({ text: "efghijkl", truncated: true });
|
||||
expect(second.text).toHaveLength(8);
|
||||
expect(WATCH_LOG_CAPTURE_MAX_CHARS).toBeGreaterThan(1024);
|
||||
});
|
||||
|
||||
it("keeps build-regression detection after diagnostic logs truncate", () => {
|
||||
const detected = updateWatchBuildDetection(
|
||||
{ buffer: "", triggered: false, reason: null },
|
||||
"Building TypeScript (dist is stale: source_mtime_newer)\n",
|
||||
);
|
||||
const afterNoise = updateWatchBuildDetection(detected, "x".repeat(10_000));
|
||||
|
||||
expect(afterNoise.triggered).toBe(true);
|
||||
expect(afterNoise.reason).toBe("source_mtime_newer");
|
||||
|
||||
const coalesced = updateWatchBuildDetection(
|
||||
{ buffer: "", triggered: false, reason: null },
|
||||
`Building TypeScript (dist is stale: config_newer)\n${"x".repeat(10_000)}`,
|
||||
);
|
||||
expect(coalesced.triggered).toBe(true);
|
||||
expect(coalesced.reason).toBe("config_newer");
|
||||
});
|
||||
|
||||
it("refreshes restored build stamps only for skip-build config mtime drift", () => {
|
||||
expect(
|
||||
shouldRefreshBuildStampForRestoredArtifacts({
|
||||
|
||||
Reference in New Issue
Block a user