Public: anyone can read this; the crew can change it.
A test reproduces the failing-test-name hold finding: a hold by substring fails on main #15134
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/15131-a-test-reproduces-the-failing-test-name → main 1 commit fork
2 files
changed +68
−2
src/crew/red_fix.ts +4 −2
| @@ -48,12 +48,14 @@ export function coveredByRedFix( | ||
| 48 | 48 | */ |
| 49 | 49 | export const MIN_NAME = 4; |
| 50 | 50 | |
| 51 | const WORD = /[\p{L}\p{N}_]/u; | |
| 51 | /** A character that continues a name: a hyphen joins `foo-bar` into one (#15131). */ | |
| 52 | const WORD = /[\p{L}\p{N}_-]/u; | |
| 52 | 53 | |
| 53 | 54 | /** |
| 54 | 55 | * Whether `text` quotes `name` whole: at least `MIN_NAME` characters once |
| 55 | 56 | * trimmed, and not part of a longer word on either side, so `a` does not |
| 56 | * match inside `panel` and `chart` does not match `charter`. | |
| 57 | * match inside `panel`, `chart` does not match `charter` and `chart` does | |
| 58 | * not match `chart-axis`. | |
| 57 | 59 | */ |
| 58 | 60 | export function quotes(text: string, name: string): boolean { |
| 59 | 61 | const needle = name.trim(); |
test/red-fix-whole-name.test.ts added +64
| @@ -0,0 +1,64 @@ | ||
| 1 | /** | |
| 2 | * The failing-test-name hold, reproduced (#15131, from #14991): while main is | |
| 3 | * red and its fix issue is open, an issue is held only when it names a failing | |
| 4 | * test whole. On a substring match (`text.includes(name)`) a test `foo` held | |
| 5 | * an issue about `foo-bar`; these cases fail against that and pass on the | |
| 6 | * whole-name match in `src/crew/red_fix.ts` (`quotes`). | |
| 7 | */ | |
| 8 | import { beforeEach, describe, expect, test } from "bun:test"; | |
| 9 | import type { Database } from "bun:sqlite"; | |
| 10 | import { migrations } from "../src/core/schema.ts"; | |
| 11 | import { openDb } from "../src/kernel/db.ts"; | |
| 12 | import { claimRun, createRun, finishRun } from "../src/core/runs.ts"; | |
| 13 | import { coveredByRedFix, quotes } from "../src/crew/red_fix.ts"; | |
| 14 | ||
| 15 | let db: Database; | |
| 16 | beforeEach(() => { | |
| 17 | db = openDb(":memory:", migrations); | |
| 18 | db.run("INSERT INTO user (id, username, email, password_hash) VALUES ('u1', 'trevato', 't@x', '')"); | |
| 19 | db.run("INSERT INTO repo (id, owner_id, name) VALUES ('r1', 'u1', 'forge')"); | |
| 20 | // The fix issue the sentinel filed for the red main, open. | |
| 21 | db.run("INSERT INTO issue (id, repo_id, number, kind, title, author_id) VALUES ('fix', 'r1', 1, 'issue', 'Fix main', 'u1')"); | |
| 22 | db.run( | |
| 23 | "INSERT INTO sentinel_finding (key, issue_id, evidence, first_seen, last_seen) VALUES ('degraded:red-r1', 'fix', '', 'x', 'x')", | |
| 24 | ); | |
| 25 | }); | |
| 26 | ||
| 27 | /** Main's last check failed on exactly `names`. */ | |
| 28 | const redOn = (...names: string[]) => { | |
| 29 | const run = createRun(db, { repoId: "r1", kind: "check", env: "main", commitOid: "b".repeat(40), reason: "push" }); | |
| 30 | claimRun(db, run.id); | |
| 31 | finishRun(db, run.id, { | |
| 32 | state: "failed", | |
| 33 | summary: "check failed", | |
| 34 | checkDetail: { passed: 1, failed: names.length, names }, | |
| 35 | }); | |
| 36 | }; | |
| 37 | ||
| 38 | const held = (title: string, body = "") => coveredByRedFix(db, "r1", { id: "i8", title, body }); | |
| 39 | ||
| 40 | describe("a failing test holds an issue only when the issue names it whole (#15131)", () => { | |
| 41 | test("an issue naming `foo-bar` is not held by a failing test `foo`", () => { | |
| 42 | redOn("foo"); | |
| 43 | // A substring match holds it: "foo-bar" contains "foo". | |
| 44 | expect("Fix `foo-bar` on main".includes("foo")).toBe(true); | |
| 45 | expect(held("Fix `foo-bar` on main", "foo-bar renders twice")).toBe(false); | |
| 46 | }); | |
| 47 | ||
| 48 | test("a name long enough to count is still not held inside a hyphenated one", () => { | |
| 49 | // Past the short-name floor, the boundary alone decides: `-` continues a name. | |
| 50 | redOn("keeps its chart"); | |
| 51 | expect(held("A panel keeps its chart-axis", "")).toBe(false); | |
| 52 | expect(held("", "pre-keeps its chart")).toBe(false); | |
| 53 | expect(quotes("keeps its chart-axis", "keeps its chart")).toBe(false); | |
| 54 | }); | |
| 55 | ||
| 56 | test("an issue that names the failing test whole is held", () => { | |
| 57 | redOn("foo-bar"); | |
| 58 | expect(held("Fix `foo-bar` on main")).toBe(true); | |
| 59 | redOn("keeps its chart"); | |
| 60 | expect(held("", 'main is red — "keeps its chart" fails')).toBe(true); | |
| 61 | expect(held("fails: keeps its chart")).toBe(true); | |
| 62 | expect(held("keeps its chart - and nothing else")).toBe(true); | |
| 63 | }); | |
| 64 | }); |
new above
offline