




















@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
22import fs from "node:fs/promises";
33import os from "node:os";
44import path from "node:path";
5-import { afterEach, beforeEach, describe, expect, it } from "vitest";
5+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
66import {
77createGauntletPrebuildCommand,
88hasGauntletWorkRows,
@@ -30,6 +30,7 @@ describe("plugin gateway gauntlet helpers", () => {
3030});
31313232afterEach(async () => {
33+vi.restoreAllMocks();
3334await fs.rm(repoRoot, { recursive: true, force: true });
3435});
3536@@ -332,9 +333,7 @@ describe("plugin gateway gauntlet helpers", () => {
332333it("does not count prebuild setup as gauntlet work", () => {
333334expect(hasGauntletWorkRows([])).toBe(false);
334335expect(hasGauntletWorkRows([{ phase: "prebuild" }])).toBe(false);
335-expect(hasGauntletWorkRows([{ phase: "prebuild" }, { phase: "lifecycle:install" }])).toBe(
336-true,
337-);
336+expect(hasGauntletWorkRows([{ phase: "prebuild" }, { phase: "lifecycle:install" }])).toBe(true);
338337expect(hasGauntletWorkRows([{ phase: "slash:help" }])).toBe(true);
339338expect(hasGauntletWorkRows([{ phase: "qa:rpc" }])).toBe(true);
340339});
@@ -434,6 +433,36 @@ describe("plugin gateway gauntlet helpers", () => {
434433expect(log).toContain("[stdout truncated after 12 bytes]");
435434});
436435436+it("bounds relayed output from live measured commands", async () => {
437+const logDir = path.join(repoRoot, "logs");
438+const writes: string[] = [];
439+vi.spyOn(process.stdout, "write").mockImplementation((chunk: string | Uint8Array) => {
440+writes.push(Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk));
441+return true;
442+});
443+444+const row = await runMeasuredCommandLive({
445+cwd: repoRoot,
446+env: process.env,
447+ logDir,
448+command: process.execPath,
449+args: ["-e", "process.stdout.write('x'.repeat(32))"],
450+label: "live-relay-bounded",
451+phase: "probe",
452+timeoutMs: 1000,
453+timeMode: "none",
454+consoleOutputMaxBytes: 12,
455+maxBufferBytes: 64,
456+});
457+458+const relayed = writes.join("");
459+expect(row.status).toBe(0);
460+expect(relayed).toContain("x".repeat(12));
461+expect(relayed).not.toContain("x".repeat(32));
462+expect(relayed).toContain("[stdout relay truncated after 12 bytes]");
463+await expect(fs.readFile(row.logPath, "utf8")).resolves.toContain("x".repeat(32));
464+});
465+437466it("force kills timed-out live measured process groups that ignore SIGTERM", async () => {
438467const logDir = path.join(repoRoot, "logs");
439468const markerPath = path.join(repoRoot, "timeout-marker.txt");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。