fix(test): improve capture reliability and runner cleanup (#609)
* test: make capture fixtures readiness-aware and strengthen assertions * fix(test): escalate child termination and report cleanup failures * perf(test): use runner concurrency and lock shared build outputs
This commit is contained in:
@@ -83,10 +83,8 @@ itWithCaptureCapability(
|
||||
},
|
||||
);
|
||||
|
||||
// Events are scheduled relative to PTY startup, so the child is already live
|
||||
// before the input, resize, and signal are delivered.
|
||||
itWithCaptureCapability(
|
||||
"captures source-owned interactive, resize, Unicode, and signal behavior",
|
||||
"captures input, Unicode, and resize across PTY startup",
|
||||
async () => {
|
||||
const result = await captureProcessScenario(
|
||||
parseProcessScenario({
|
||||
@@ -94,9 +92,8 @@ itWithCaptureCapability(
|
||||
arguments: [processFixture, "interactive"],
|
||||
working_directory: dirname(processFixture),
|
||||
events: [
|
||||
{ type: "input", at_ms: 200, data: "answer" },
|
||||
{ type: "resize", at_ms: 400, columns: 100, rows: 40 },
|
||||
{ type: "signal", at_ms: 700, signal: "SIGINT" },
|
||||
{ type: "resize", at_ms: 0, columns: 100, rows: 40 },
|
||||
{ type: "input", at_ms: 0, data: "answer\n" },
|
||||
],
|
||||
normalization: { time_bucket_ms: 10 },
|
||||
timeout_ms: 20_000,
|
||||
@@ -109,9 +106,15 @@ itWithCaptureCapability(
|
||||
expect(output).toContain("prompt>");
|
||||
expect(output).toContain("input:answer unicode:雪");
|
||||
expect(output).toContain("resize:100x40");
|
||||
expect(output).toContain("signal:SIGINT");
|
||||
expect(result.value.interaction_events).toMatchObject([
|
||||
{ type: "resize", outcome: "dispatched", scheduled_at_ms: 0 },
|
||||
{ type: "input", outcome: "dispatched", scheduled_at_ms: 0 },
|
||||
]);
|
||||
const resized = result.value.rendered_frames.find(
|
||||
({ columns, rows }) => columns === 100 && rows === 40,
|
||||
({ columns, rows, lines }) =>
|
||||
columns === 100 &&
|
||||
rows === 40 &&
|
||||
lines.join("\n").includes("input:answer unicode:雪"),
|
||||
);
|
||||
expect(resized).toBeDefined();
|
||||
expect(resized?.lines.join("\n")).toContain("input:answer unicode:雪");
|
||||
@@ -120,7 +123,29 @@ itWithCaptureCapability(
|
||||
);
|
||||
|
||||
itWithCaptureCapability(
|
||||
"dispatches scheduled events before a silent PTY produces output",
|
||||
"dispatches an external signal without depending on child startup output",
|
||||
async () => {
|
||||
const result = await captureProcessScenario(
|
||||
parseProcessScenario({
|
||||
executable: process.execPath,
|
||||
arguments: [processFixture, "hang"],
|
||||
working_directory: dirname(processFixture),
|
||||
events: [{ type: "signal", at_ms: 0, signal: "SIGTERM" }],
|
||||
timeout_ms: 2_000,
|
||||
idle_timeout_ms: 2_000,
|
||||
}),
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.interaction_events).toMatchObject([
|
||||
{ type: "signal", data: "SIGTERM", outcome: "dispatched" },
|
||||
]);
|
||||
expect(result.value.exit).toMatchObject({ signal: 15, reason: "exited" });
|
||||
},
|
||||
);
|
||||
|
||||
itWithCaptureCapability(
|
||||
"buffers newline input until a silent PTY fixture is ready to read it",
|
||||
async () => {
|
||||
const result = await captureProcessScenario(
|
||||
parseProcessScenario({
|
||||
@@ -129,10 +154,10 @@ itWithCaptureCapability(
|
||||
working_directory: dirname(processFixture),
|
||||
events: [
|
||||
{ type: "resize", at_ms: 25, columns: 100, rows: 40 },
|
||||
{ type: "input", at_ms: 50, data: "answer" },
|
||||
{ type: "input", at_ms: 50, data: "answer\n" },
|
||||
],
|
||||
timeout_ms: 2_000,
|
||||
idle_timeout_ms: 2_000,
|
||||
timeout_ms: 20_000,
|
||||
idle_timeout_ms: 20_000,
|
||||
}),
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
@@ -141,9 +166,19 @@ itWithCaptureCapability(
|
||||
"input:answer",
|
||||
);
|
||||
expect(result.value.interaction_events).toMatchObject([
|
||||
{ type: "resize", outcome: "dispatched" },
|
||||
{ type: "input", outcome: "dispatched" },
|
||||
{ type: "resize", scheduled_at_ms: 25, outcome: "dispatched" },
|
||||
{ type: "input", scheduled_at_ms: 50, outcome: "dispatched" },
|
||||
]);
|
||||
expect(
|
||||
result.value.interaction_events.every(
|
||||
({ scheduled_at_ms, dispatched_at_ms }) =>
|
||||
dispatched_at_ms >= scheduled_at_ms,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
result.value.frames.find(({ data }) => data.includes("input:answer"))
|
||||
?.at_ms,
|
||||
).toBeGreaterThanOrEqual(50);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -155,12 +190,16 @@ itWithCaptureCapability(
|
||||
executable: process.execPath,
|
||||
arguments: [processFixture, "tree"],
|
||||
working_directory: dirname(processFixture),
|
||||
timeout_ms: 2_000,
|
||||
idle_timeout_ms: 2_000,
|
||||
timeout_ms: 20_000,
|
||||
idle_timeout_ms: 20_000,
|
||||
}),
|
||||
);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.exit).toMatchObject({ code: 0, reason: "exited" });
|
||||
expect(result.value.frames.map(({ data }) => data).join("")).toContain(
|
||||
"tree-ready",
|
||||
);
|
||||
const commands = result.value.process_samples.map(({ command }) => command);
|
||||
expect(commands.some((command) => command.includes("tree-child"))).toBe(
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user