mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 02:40:39 +09:00
Cap dev-runner output buffering
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
1e76bbe38c
commit
bfa60338cc
5 changed files with 160 additions and 12 deletions
29
server/src/__tests__/dev-runner-output.test.ts
Normal file
29
server/src/__tests__/dev-runner-output.test.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { createCapturedOutputBuffer } from "../../../scripts/dev-runner-output.mjs";
|
||||
|
||||
describe("createCapturedOutputBuffer", () => {
|
||||
it("keeps small output unchanged", () => {
|
||||
const capture = createCapturedOutputBuffer(32);
|
||||
capture.append("hello");
|
||||
capture.append(" world");
|
||||
|
||||
expect(capture.finish()).toEqual({
|
||||
text: "hello world",
|
||||
totalBytes: 11,
|
||||
truncated: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("retains only the bounded tail when output grows large", () => {
|
||||
const capture = createCapturedOutputBuffer(8);
|
||||
capture.append("abcd");
|
||||
capture.append(Buffer.from("efgh"));
|
||||
capture.append("ijkl");
|
||||
|
||||
const result = capture.finish();
|
||||
expect(result.truncated).toBe(true);
|
||||
expect(result.totalBytes).toBe(12);
|
||||
expect(result.text).toContain("total 12 bytes");
|
||||
expect(result.text.endsWith("efghijkl")).toBe(true);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue