Public: anyone can read this; the crew can change it.
A pull's red that the lane hasn't counted yet is asked of main: its failing files rerun once at the pull's base #17391
Merged 20h 20m ago, live in production
feat/without-patch-rerun → main 0 commits
4 files
changed +246
−42
src/checks/execute.ts +75 −13
| @@ -15,7 +15,7 @@ import type { Database } from "bun:sqlite"; | ||
| 15 | 15 | import { bisectOrigin, inVerifyLane, safeFile, VERIFY_ENV, VERIFY_REASON } from "./verify.ts"; |
| 16 | 16 | import { SHARED_VERIFY_MS, verifyForSharedRed } from "./shared_verify.ts"; |
| 17 | 17 | import { SHARED_PULLS } from "./shared_red.ts"; |
| 18 | import { knownRedPass } from "./known_red.ts"; | |
| 18 | import { knownRedPass, WITHOUT_PATCH_MS, withoutPatchPass } from "./known_red.ts"; | |
| 19 | 19 | import { resolveOid } from "../git/merge.ts"; |
| 20 | 20 | import { repoDir } from "../git/repos.ts"; |
| 21 | 21 | import { getIssueById } from "../core/issues.ts"; |
| @@ -98,7 +98,11 @@ export async function execute( | ||
| 98 | 98 | // A check that writes nothing and is offered to no runner is left, not waited for: its slot |
| 99 | 99 | // is freed even when the runner never answers the abort (#16105). |
| 100 | 100 | const stall = watchStall(options.stallMs ?? STALL_MS, () => wrote, () => offeredToRunner(app.db, run.id)); |
| 101 | const ran = check(lane, claimed, repo, write, budget.signal); | |
| 101 | // A pull's red is weighed inside the check's own time, lease and budget: the lane's known red | |
| 102 | // passes it, and a red the lane hasn't counted yet is asked of main (`known_red.ts`). | |
| 103 | const ran = check(lane, claimed, repo, write, budget.signal).then((r) => | |
| 104 | r.ok ? r : weighRed(lane, repo, run.id, r, write, budget.signal, () => limit - (Date.now() - started)), | |
| 105 | ); | |
| 102 | 106 | ran.catch(() => {}); |
| 103 | 107 | const result = await Promise.race([ran, stall.stalled]).finally(() => { |
| 104 | 108 | stall.stop(); |
| @@ -121,17 +125,7 @@ export async function execute( | ||
| 121 | 125 | if (failed) announceRun(app, failed); |
| 122 | 126 | return; |
| 123 | 127 | } |
| 124 | // A pull's red on nothing but the lane's known red passes, saying so (`known_red.ts`). Read | |
| 125 | // afresh: the check recorded the base it was built on (`tier_source.ts`) after `run` was read. | |
| 126 | const known = result.ok | |
| 127 | ? undefined | |
| 128 | : await knownRedPass(app, repo, getRun(app.db, run.id) ?? run, result.detail).catch((error: unknown) => { | |
| 129 | // The red stands; the log says why no pass was weighed. | |
| 130 | write(`known-red: not weighed (${String(error).slice(0, 200)}); the red stands`); | |
| 131 | return undefined; | |
| 132 | }); | |
| 133 | if (known !== undefined) write(known); | |
| 134 | const outcome: typeof result = known === undefined ? result : { ok: true, cleared: known, ...(result.plan === undefined ? {} : { plan: result.plan }) }; | |
| 128 | const outcome = result; | |
| 135 | 129 | // Where a check cut off here is asked again. A verification is of the |
| 136 | 130 | // default branch as it stands: it goes back at the branch's newest |
| 137 | 131 | // checked commit, the one `askVerifications` would ask of. Left at the |
| @@ -301,6 +295,74 @@ export async function execute( | ||
| 301 | 295 | } |
| 302 | 296 | } |
| 303 | 297 | |
| 298 | /** | |
| 299 | * A pull's red, weighed: passed when it is the lane's known red, or when its failing files fail on | |
| 300 | * main at the pull's base too (asked once, `withoutPatchPass`); otherwise the red, with what main | |
| 301 | * said kept on its detail. The run is read afresh: the check recorded its base (`tier_source.ts`) | |
| 302 | * after the lane read it. Never throws: a red that can't be weighed stands, its log saying why. | |
| 303 | */ | |
| 304 | async function weighRed( | |
| 305 | lane: LaneState, | |
| 306 | repo: Repo, | |
| 307 | runId: string, | |
| 308 | red: Extract<CheckOutcome, { ok: false }>, | |
| 309 | write: (line: string) => void, | |
| 310 | signal: AbortSignal, | |
| 311 | left: () => number, | |
| 312 | ): Promise<CheckOutcome> { | |
| 313 | const { app } = lane; | |
| 314 | const run = getRun(app.db, runId); | |
| 315 | if (run === undefined) return red; | |
| 316 | const pass = (words: string): CheckOutcome => { | |
| 317 | write(words); | |
| 318 | return { ok: true, cleared: words, ...(red.plan === undefined ? {} : { plan: red.plan }) }; | |
| 319 | }; | |
| 320 | try { | |
| 321 | const known = await knownRedPass(app, repo, run, red.detail); | |
| 322 | if (known !== undefined) return pass(known); | |
| 323 | } catch (error) { | |
| 324 | write(`known-red: not weighed (${String(error).slice(0, 200)}); the red stands`); | |
| 325 | return red; | |
| 326 | } | |
| 327 | try { | |
| 328 | const answer = await withoutPatchPass(app, repo, run, red.detail, (files, base) => | |
| 329 | left() < WITHOUT_PATCH_MS | |
| 330 | ? Promise.resolve<CheckOutcome>({ ok: false, error: "the check has less time left than a rerun may take", infrastructure: true }) | |
| 331 | : lane.runner.run(withoutPatchJob(run, base, files), { | |
| 332 | write: (line) => write(`without patch | ${line}`), | |
| 333 | signal: AbortSignal.any([signal, AbortSignal.timeout(WITHOUT_PATCH_MS)]), | |
| 334 | }), | |
| 335 | ); | |
| 336 | if (answer === undefined) return red; | |
| 337 | write(answer.said); | |
| 338 | if (answer.words !== undefined) return pass(answer.words); | |
| 339 | return red.detail === undefined ? red : { ...red, detail: { ...red.detail, withoutPatch: answer.record } }; | |
| 340 | } catch (error) { | |
| 341 | write(`without patch: not run (${String(error).slice(0, 200)}); the red stands`); | |
| 342 | return red; | |
| 343 | } | |
| 344 | } | |
| 345 | ||
| 346 | /** | |
| 347 | * The job that runs a pull's failing files at its base, the pull left out, with main's commands | |
| 348 | * there. | |
| 349 | */ | |
| 350 | export function withoutPatchJob(run: Pick<Run, "id" | "repoId">, base: string, files: readonly string[]): CheckJob { | |
| 351 | return { | |
| 352 | runId: run.id, | |
| 353 | repoId: run.repoId, | |
| 354 | commitOid: base, | |
| 355 | issueId: null, | |
| 356 | tier: "verify", | |
| 357 | only: files, | |
| 358 | commandsFrom: base, | |
| 359 | keep: false, | |
| 360 | keepImpact: false, | |
| 361 | fileOrderDependent: false, | |
| 362 | isMain: false, | |
| 363 | }; | |
| 364 | } | |
| 365 | ||
| 304 | 366 | /** |
| 305 | 367 | * Each red file of a red verification run alone on the same commit, once (#14404): whether it |
| 306 | 368 | * passed alone, its wall time and how many other checks were running when it started (#15240), so |
src/checks/known_red.ts +101 −21
| @@ -16,15 +16,25 @@ | ||
| 16 | 16 | * The impact map is the one an earlier verification kept (`impact-store.ts`), not this pull's: a |
| 17 | 17 | * file the pull added that the test now reaches is not in it, so the guardrail cannot see it; and a |
| 18 | 18 | * repository with no kept map, or a test the map does not know, keeps its red. |
| 19 | * | |
| 20 | * Without the patch (Chromium's "without patch" retry): a red that passes every guard but the | |
| 21 | * lane's count, fewer than SHARED_PULLS pulls yet, is asked of main itself. The failing files run | |
| 22 | * once at the pull's base, the pull left out ({@link withoutPatchPass}); the same tests failing | |
| 23 | * there pass the check at once, "known-red: <test> (fails on main at <base>)", and their passing | |
| 24 | * there keeps the red as the pull's own. A rerun that can't answer (no base, no runner, out of | |
| 25 | * time) keeps the red and says why. On 2026-12-01 it would have cleared 17 reds 14.1 hours sooner | |
| 26 | * than the count. | |
| 19 | 27 | */ |
| 20 | 28 | |
| 21 | 29 | import type { App } from "../app.ts"; |
| 22 | 30 | import type { Repo } from "../core/repos.ts"; |
| 23 | import type { CheckDetail, Run } from "../core/runs.ts"; | |
| 31 | import type { CheckDetail, Run, WithoutPatch } from "../core/runs.ts"; | |
| 24 | 32 | import { runGit } from "../git/env.ts"; |
| 25 | 33 | import { repoDir } from "../git/repos.ts"; |
| 26 | 34 | import { keptImpact } from "./impact-store.ts"; |
| 35 | import type { CheckOutcome } from "./runner.ts"; | |
| 27 | 36 | import { flakeHref, NO_TEST_NAME, sharedWithPulls } from "./shared_red.ts"; |
| 37 | import { safeFile } from "./verify.ts"; | |
| 28 | 38 | |
| 29 | 39 | /** The files a pull changed between its base and its commit; `undefined` when git can't say. */ |
| 30 | 40 | async function changedFiles(bare: string, base: string, commit: string): Promise<string[] | undefined> { |
| @@ -33,6 +43,37 @@ async function changedFiles(bare: string, base: string, commit: string): Promise | ||
| 33 | 43 | return diff.ok ? diff.value.split("\n").filter((f) => f !== "") : undefined; |
| 34 | 44 | } |
| 35 | 45 | |
| 46 | type Weighed = Pick<Run, "repoId" | "issueId" | "env" | "commitOid" | "baseOid">; | |
| 47 | ||
| 48 | /** | |
| 49 | * A pull check's red, when it can be weighed at all: every test named, each to a file whose | |
| 50 | * executed files the kept impact map knows, and none of them changed by the pull. `undefined` keeps | |
| 51 | * the red as the pull's own. | |
| 52 | */ | |
| 53 | async function untouched(app: App, repo: Repo, run: Weighed, detail: CheckDetail | undefined): Promise<{ names: readonly string[]; files: string[] } | undefined> { | |
| 54 | if (run.issueId === null || !run.env.startsWith("pull-") || detail === undefined) return undefined; | |
| 55 | const names = detail.names; | |
| 56 | if (names.length === 0 || names.includes(NO_TEST_NAME)) return undefined; | |
| 57 | // Each red named to its test file, and what that file executes known. | |
| 58 | const files = new Map((detail.failures ?? []).map((f) => [f.name, f.file] as const)); | |
| 59 | const impact = keptImpact(app.config.dataDir, run.repoId); | |
| 60 | if (impact === undefined) return undefined; | |
| 61 | const reach = new Set<string>(); | |
| 62 | const tested = new Set<string>(); | |
| 63 | for (const name of names) { | |
| 64 | const file = files.get(name); | |
| 65 | const executes = file === undefined ? undefined : impact.get(file); | |
| 66 | if (file === undefined || executes === undefined) return undefined; | |
| 67 | reach.add(file); | |
| 68 | tested.add(file); | |
| 69 | for (const f of executes) reach.add(f); | |
| 70 | } | |
| 71 | // A pull that changed the test or anything it executes keeps its red. | |
| 72 | const changed = await changedFiles(repoDir(app.reposRoot, repo.ownerName, repo.name), run.baseOid, run.commitOid); | |
| 73 | if (changed === undefined || changed.some((f) => reach.has(f))) return undefined; | |
| 74 | return { names, files: [...tested] }; | |
| 75 | } | |
| 76 | ||
| 36 | 77 | /** |
| 37 | 78 | * The words a red pull check passes with, when every test it failed is the lane's known red and |
| 38 | 79 | * the pull touched none of them; `undefined` when it keeps its red. |
| @@ -40,30 +81,15 @@ async function changedFiles(bare: string, base: string, commit: string): Promise | ||
| 40 | 81 | export async function knownRedPass( |
| 41 | 82 | app: App, |
| 42 | 83 | repo: Repo, |
| 43 | run: Pick<Run, "repoId" | "issueId" | "env" | "commitOid" | "baseOid">, | |
| 84 | run: Weighed, | |
| 44 | 85 | detail: CheckDetail | undefined, |
| 45 | 86 | now: number = Date.now(), |
| 46 | 87 | ): Promise<string | undefined> { |
| 47 | if (run.issueId === null || !run.env.startsWith("pull-") || detail === undefined) return undefined; | |
| 48 | const names = detail.names; | |
| 49 | if (names.length === 0 || names.includes(NO_TEST_NAME)) return undefined; | |
| 50 | 88 | // Each red is the lane's: failed by SHARED_PULLS or more other pulls in the hour, not their own. |
| 51 | if (!sharedWithPulls(app.db, { repoId: run.repoId, checkDetail: detail }, now)) return undefined; | |
| 52 | // Each red named to its test file, and what that file executes known. | |
| 53 | const files = new Map((detail.failures ?? []).map((f) => [f.name, f.file] as const)); | |
| 54 | const impact = keptImpact(app.config.dataDir, run.repoId); | |
| 55 | if (impact === undefined) return undefined; | |
| 56 | const reach = new Set<string>(); | |
| 57 | for (const name of names) { | |
| 58 | const file = files.get(name); | |
| 59 | const executes = file === undefined ? undefined : impact.get(file); | |
| 60 | if (file === undefined || executes === undefined) return undefined; | |
| 61 | reach.add(file); | |
| 62 | for (const f of executes) reach.add(f); | |
| 63 | } | |
| 64 | // A pull that changed the test or anything it executes keeps its red. | |
| 65 | const changed = await changedFiles(repoDir(app.reposRoot, repo.ownerName, repo.name), run.baseOid, run.commitOid); | |
| 66 | if (changed === undefined || changed.some((f) => reach.has(f))) return undefined; | |
| 89 | if (detail === undefined || !sharedWithPulls(app.db, { repoId: run.repoId, checkDetail: detail }, now)) return undefined; | |
| 90 | const weighed = await untouched(app, repo, run, detail); | |
| 91 | if (weighed === undefined) return undefined; | |
| 92 | const names = weighed.names; | |
| 67 | 93 | const full = `${repo.ownerName}/${repo.name}`; |
| 68 | 94 | return names |
| 69 | 95 | .map((test) => { |
| @@ -73,3 +99,57 @@ export async function knownRedPass( | ||
| 73 | 99 | }) |
| 74 | 100 | .join("; "); |
| 75 | 101 | } |
| 102 | ||
| 103 | /** The longest a rerun without the patch may take; past it the red stands. */ | |
| 104 | export const WITHOUT_PATCH_MS = 10 * 60_000; | |
| 105 | ||
| 106 | /** | |
| 107 | * What asking main said of a red: `words` when the same tests fail there too (the check passes with | |
| 108 | * them), and always `said`, the log's line, and `record`, kept on the red's detail. | |
| 109 | */ | |
| 110 | export interface WithoutPatchAnswer { | |
| 111 | readonly said: string; | |
| 112 | readonly words?: string; | |
| 113 | readonly record: WithoutPatch; | |
| 114 | } | |
| 115 | ||
| 116 | /** | |
| 117 | * A red that {@link knownRedPass} did not pass, asked of main: its failing files run once at the | |
| 118 | * pull's base by `rerun`, the pull left out. `undefined` when it isn't asked (not a pull's check, a | |
| 119 | * test the pull touched or the map can't place); the caller asks once per red check, and the rerun | |
| 120 | * is no check of its own, so it never asks again. | |
| 121 | */ | |
| 122 | export async function withoutPatchPass( | |
| 123 | app: App, | |
| 124 | repo: Repo, | |
| 125 | run: Weighed, | |
| 126 | detail: CheckDetail | undefined, | |
| 127 | rerun: (files: readonly string[], base: string) => Promise<CheckOutcome>, | |
| 128 | ): Promise<WithoutPatchAnswer | undefined> { | |
| 129 | const weighed = await untouched(app, repo, run, detail); | |
| 130 | if (weighed === undefined) return undefined; | |
| 131 | const files = weighed.files.filter(safeFile); | |
| 132 | const base = run.baseOid; | |
| 133 | const at = base.slice(0, 8); | |
| 134 | const kept = (outcome: WithoutPatch["outcome"], why: string): WithoutPatchAnswer => ({ | |
| 135 | said: `without patch: ${why}; the red stands`, | |
| 136 | record: { base, files, outcome }, | |
| 137 | }); | |
| 138 | if (base === "") return kept("not answered", "not run, the check recorded no base"); | |
| 139 | if (files.length !== weighed.files.length) return kept("not answered", "not run, a test file's path is not one to hand a runner"); | |
| 140 | const outcome = await rerun(files, base).catch((error): CheckOutcome => ({ ok: false, error: String(error), infrastructure: true })); | |
| 141 | if (outcome.ok) return kept("passed", `${files.join(", ")} passed on main at ${at}, so the red is this pull's`); | |
| 142 | if (outcome.infrastructure === true || outcome.killed === true || outcome.cpuStop !== undefined) | |
| 143 | return kept("not answered", `${files.join(", ")} not answered at ${at} (${outcome.error.slice(0, 200)})`); | |
| 144 | if ((outcome.detail?.names ?? []).length === 0) | |
| 145 | return kept("not answered", `main at ${at} failed without naming a test (${outcome.error.slice(0, 200)})`); | |
| 146 | const there = new Set(outcome.detail?.names ?? []); | |
| 147 | const missing = weighed.names.filter((n) => !there.has(n)); | |
| 148 | if (missing.length > 0) | |
| 149 | return kept("passed", `main at ${at} failed, but not ${missing.map((n) => `"${n}"`).join(", ")}, so the red is this pull's`); | |
| 150 | return { | |
| 151 | said: `without patch: ${files.join(", ")} failed on main at ${at} too`, | |
| 152 | words: weighed.names.map((test) => `known-red: "${test}" (fails on main at ${at})`).join("; "), | |
| 153 | record: { base, files, outcome: "failed too" }, | |
| 154 | }; | |
| 155 | } |
src/core/runs.ts +11
| @@ -70,6 +70,17 @@ export interface CheckDetail { | ||
| 70 | 70 | readonly diskFree?: number; |
| 71 | 71 | /** `temp_full`: a shard ran out of temp space, the environment's fault, not the change's (#8679). */ |
| 72 | 72 | readonly environment?: "temp_full"; |
| 73 | /** | |
| 74 | * A pull's red asked of main: its failing files rerun once at the pull's base (`known_red.ts`). | |
| 75 | */ | |
| 76 | readonly withoutPatch?: WithoutPatch; | |
| 77 | } | |
| 78 | ||
| 79 | /** What a pull's failing files did at its base, the pull left out. */ | |
| 80 | export interface WithoutPatch { | |
| 81 | readonly base: string; | |
| 82 | readonly files: readonly string[]; | |
| 83 | readonly outcome: "failed too" | "passed" | "not answered"; | |
| 73 | 84 | } |
| 74 | 85 | |
| 75 | 86 | export interface Run { |
test/known-red-check.test.ts +59 −8
| @@ -2,6 +2,9 @@ | ||
| 2 | 2 | * A pull check whose only red is the lane's known red finishes ok, its summary saying so; one whose |
| 3 | 3 | * red is its own stays failed (`execute.ts` asking `checks/known_red.ts`). Through the real check |
| 4 | 4 | * lane with its check step stood in: the step prints what bun prints for one failing test. |
| 5 | * | |
| 6 | * A red the lane hasn't counted is asked of main (`withoutPatchPass`): the stand-in step answers | |
| 7 | * main's rerun (the job that names its files, `FORGE_CHECK_ONLY`) as `main` says. | |
| 5 | 8 | */ |
| 6 | 9 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 7 | 10 | import { mkdirSync, mkdtemp } from "node:fs"; |
| @@ -17,14 +20,19 @@ import { startChecks } from "../src/checks/service.ts"; | ||
| 17 | 20 | import type { Repo } from "../src/core/repos.ts"; |
| 18 | 21 | import { claimRun, createRun, finishRun, listRuns, type CheckDetail, type Run } from "../src/core/runs.ts"; |
| 19 | 22 | import { createUser, type User } from "../src/core/users.ts"; |
| 20 | import { err } from "../src/kernel/result.ts"; | |
| 23 | import { err, ok } from "../src/kernel/result.ts"; | |
| 21 | 24 | import { quietLogs } from "./helpers/globals.ts"; |
| 22 | 25 | import { waitFor } from "./helpers/poll.ts"; |
| 23 | 26 | |
| 24 | 27 | quietLogs(); |
| 25 | 28 | |
| 26 | 29 | const X = "the lane > fails for everyone"; |
| 27 | const said = ["test/x.test.ts:", `(fail) ${X}`, " 10 pass", " 1 fail", "Ran 11 tests across 3 files."]; | |
| 30 | const said = (name: string) => ["test/x.test.ts:", `(fail) ${name}`, " 10 pass", " 1 fail", "Ran 11 tests across 3 files."]; | |
| 31 | const greenSaid = (name: string) => ["test/x.test.ts:", `(pass) ${name}`, " 11 pass", " 0 fail", "Ran 11 tests across 3 files."]; | |
| 32 | /** What main's rerun at the pull's base does: fails the test too, passes it, or can't run. */ | |
| 33 | let main: "red" | "green" | "broken" = "red"; | |
| 34 | /** Each job main's rerun was asked for: the files it was handed. */ | |
| 35 | const askedOfMain: string[] = []; | |
| 28 | 36 | const red = (): CheckDetail => ({ passed: 10, failed: 1, names: [X], failures: [{ file: "test/x.test.ts", name: X }] }); |
| 29 | 37 | |
| 30 | 38 | const priorCells = process.env["FORGE_CELLS"]; // env-restored: afterAll |
| @@ -47,7 +55,7 @@ beforeAll(async () => { | ||
| 47 | 55 | const base = await commitToBranch(app, alice, repo, { |
| 48 | 56 | message: "base", |
| 49 | 57 | files: [ |
| 50 | { path: "forge.json", content: JSON.stringify({ check: { run: "true", install: "" } }) }, | |
| 58 | { path: "forge.json", content: JSON.stringify({ check: { run: "true", verify: "true", install: "" } }) }, | |
| 51 | 59 | { path: "src/a.ts", content: "export const a = 1;\n" }, |
| 52 | 60 | { path: "test/x.test.ts", content: "// x\n" }, |
| 53 | 61 | ], |
| @@ -74,10 +82,10 @@ afterAll(async () => { | ||
| 74 | 82 | await rm(dir, { recursive: true, force: true }); |
| 75 | 83 | }); |
| 76 | 84 | |
| 77 | /** A pull changing `path`; with `check`, its check through the lane, its step failing X. */ | |
| 78 | async function pull(path: string, check: true): Promise<Run>; | |
| 85 | /** A pull changing `path`; with `check`, its check through the lane, its step failing `name`. */ | |
| 86 | async function pull(path: string, check: true, name?: string): Promise<Run>; | |
| 79 | 87 | async function pull(path: string, check: false): Promise<{ id: string; number: number }>; |
| 80 | async function pull(path: string, check: boolean): Promise<Run | { id: string; number: number }> { | |
| 88 | async function pull(path: string, check: boolean, name = X): Promise<Run | { id: string; number: number }> { | |
| 81 | 89 | const branch = `b${++n}`; |
| 82 | 90 | const c = await commitToBranch(app, alice, repo, { branch, message: branch, files: [{ path, content: `${branch}\n` }] }); |
| 83 | 91 | if (!c.ok) throw new Error(JSON.stringify(c.error)); |
| @@ -88,8 +96,15 @@ async function pull(path: string, check: boolean): Promise<Run | { id: string; n | ||
| 88 | 96 | } |
| 89 | 97 | const checkStep: typeof runStep = (step, command, options) => { |
| 90 | 98 | if (step !== "check") return runStep(step, command, options); |
| 91 | // `runStep` echoes its command first; the lane reads what follows. | |
| 92 | for (const line of [`$ ${command}`, ...said]) options.log(line); | |
| 99 | const only = options.env["FORGE_CHECK_ONLY"]; | |
| 100 | if (only !== undefined) { | |
| 101 | askedOfMain.push(only); | |
| 102 | if (main === "broken") return Promise.reject(new Error("the runner went away")); | |
| 103 | // `runStep` echoes its command first; the lane reads what follows. | |
| 104 | for (const line of [`$ ${command}`, ...(main === "red" ? said(name) : greenSaid(name))]) options.log(line); | |
| 105 | return Promise.resolve(main === "red" ? err("check exited with code 1") : ok(undefined)); | |
| 106 | } | |
| 107 | for (const line of [`$ ${command}`, ...said(name)]) options.log(line); | |
| 93 | 108 | return Promise.resolve(err("check exited with code 1")); |
| 94 | 109 | }; |
| 95 | 110 | const checks = startChecks(app, { forgeUrl: "http://forge.test", concurrency: 1, checkStep }); |
| @@ -118,3 +133,39 @@ test("a pull whose red is its own (it changed what the test executes) stays fail | ||
| 118 | 133 | expect(run.state).toBe("failed"); |
| 119 | 134 | expect(run.summary).not.toContain("known-red"); |
| 120 | 135 | }, 60_000); |
| 136 | ||
| 137 | test("a red no other pull shares yet, failing on main at the pull's base too, passes at once", async () => { | |
| 138 | main = "red"; | |
| 139 | askedOfMain.length = 0; | |
| 140 | const run = await pull("src/c.ts", true, "main > fails here too"); | |
| 141 | expect(askedOfMain).toEqual(["test/x.test.ts"]); | |
| 142 | expect(run.state).toBe("ok"); | |
| 143 | expect(run.summary).toContain(`known-red: "main > fails here too" (fails on main at ${run.baseOid.slice(0, 8)})`); | |
| 144 | }, 60_000); | |
| 145 | ||
| 146 | test("a red that main passes at the pull's base is the pull's own: it stays failed, main's answer kept", async () => { | |
| 147 | main = "green"; | |
| 148 | askedOfMain.length = 0; | |
| 149 | const run = await pull("src/d.ts", true, "main > passes here"); | |
| 150 | expect(askedOfMain).toEqual(["test/x.test.ts"]); | |
| 151 | expect(run.state).toBe("failed"); | |
| 152 | expect(run.checkDetail?.withoutPatch).toEqual({ base: run.baseOid, files: ["test/x.test.ts"], outcome: "passed" }); | |
| 153 | }, 60_000); | |
| 154 | ||
| 155 | test("a rerun on main that can't answer keeps the red, and says why", async () => { | |
| 156 | main = "broken"; | |
| 157 | askedOfMain.length = 0; | |
| 158 | const run = await pull("src/e.ts", true, "main > never answers"); | |
| 159 | expect(askedOfMain).toEqual(["test/x.test.ts"]); | |
| 160 | expect(run.state).toBe("failed"); | |
| 161 | expect(run.checkDetail?.withoutPatch?.outcome).toBe("not answered"); | |
| 162 | }, 60_000); | |
| 163 | ||
| 164 | test("a pull that touched what the test executes is never asked of main", async () => { | |
| 165 | main = "red"; | |
| 166 | askedOfMain.length = 0; | |
| 167 | const run = await pull("src/a.ts", true, "main > touched"); | |
| 168 | expect(askedOfMain).toEqual([]); | |
| 169 | expect(run.state).toBe("failed"); | |
| 170 | expect(run.checkDetail?.withoutPatch).toBeUndefined(); | |
| 171 | }, 60_000); |
new above
offline