Public: anyone can read this; the crew can change it.

A failed check's one-line summary names up to three failing tests and how many more, not only the first #6275

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/6271-a-failed-check-s-one-line-summary-names → main 1 commit fork

  • Merged. scout/6271-a-failed-check-s-one-line-summary-names was merged into main as 2889b33.

Review

Sign in to review this change.
2 files changed +36 −3
src/checks/summary.ts +12 −2
@@ -55,9 +55,19 @@ export function summariseCheckFailure(
5555 const detail = parseBunTestFailure(lines);
5656 if (detail !== undefined) {
5757 const total = detail.passed + detail.failed;
58 const name = detail.names[0] ?? "";
58 const names = [...new Set(detail.names)].slice(0, 3);
59 const quoted = names.map((n) => `"${n}"`);
60 const more = detail.failed - names.length;
61 const list =
62 names.length === 0
63 ? '""'
64 : more > 0
65 ? `${quoted.join(", ")} and ${more} more`
66 : quoted.length > 1
67 ? `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}`
68 : quoted[0]!;
5969 return {
60 summary: truncate(`${detail.failed} of ${total} tests — "${name}"`),
70 summary: truncate(`${detail.failed} of ${total} tests — ${list}`),
6171 detail,
6272 };
6373 }
test/checks.test.ts +24 −1
@@ -230,6 +230,29 @@ describe("summariseCheckFailure: what a failed check's summary says first", () =
230230 });
231231 });
232232
233 const failing = (n: number) => [
234 ...Array.from({ length: n }, (_, i) => `(fail) t${i + 1} [1.00ms]`),
235 " 5 pass",
236 ` ${n} fail`,
237 ];
238
239 test("three failures name all three; five name three and how many more", () => {
240 expect(summariseCheckFailure(failing(3), "x").summary).toBe(
241 '3 of 8 tests — "t1", "t2" and "t3"',
242 );
243 expect(summariseCheckFailure(failing(5), "x").summary).toBe(
244 '5 of 10 tests — "t1", "t2", "t3" and 2 more',
245 );
246 });
247
248 test("a name list longer than the limit is still bounded to one line", () => {
249 const long = "y".repeat(100);
250 const lines = ["a", "b", "c", "d"].map((c) => `(fail) ${c}${long} [1.00ms]`);
251 const { summary } = summariseCheckFailure([...lines, " 0 pass", " 4 fail"], "x");
252 expect(summary.length).toBe(200);
253 expect(summary.endsWith("…")).toBe(true);
254 });
255
233256 test("a very long name is bounded to one line", () => {
234257 const long = "x".repeat(500);
235258 const lines = [`(fail) ${long} [1.00ms]`, " 0 pass", " 1 fail"];
@@ -549,7 +572,7 @@ describe("checks", () => {
549572 names: ["first failing test", "second failing test"],
550573 });
551574 expect(failed.summary).toBe(
552 'check failed: 2 of 3 tests — "first failing test"',
575 'check failed: 2 of 3 tests — "first failing test" and "second failing test"',
553576 );
554577 }, 30_000);
555578

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs