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

test/pulls-merge-budget.test.ts once answered a conflict where there is none #17700

opened this in answer to

Merged 17h 36m ago, live in production

scout/forge:scout/17698-test-pulls-merge-budget-test-ts-once-ans → main 0 commits fork

  • Merged. scout/17698-test-pulls-merge-budget-test-ts-once-ans was merged into main as 82c923d.

Review

Sign in to review this change.
1 file changed +12 −1
test/pulls-merge-budget.test.ts +12 −1
@@ -51,12 +51,15 @@ const pullOf = (i: number): Pull =>
5151 let calls = 0;
5252 let running = 0;
5353 let most = 0;
54 /** While set, no reading finishes: the budget alone decides what a list has. */
55 let gate: Promise<void> | null = null;
5456 const slow: typeof mergeable = async (d, base, head) => {
5557 calls++;
5658 running++;
5759 most = Math.max(most, running);
5860 try {
5961 await Bun.sleep(SLOW_MS);
62 if (gate !== null) await gate;
6063 return await mergeable(d, base, head);
6164 } finally {
6265 running--;
@@ -96,6 +99,12 @@ test("50 pulls, a slow merge check, main moves: the list answers in under 1 s an
9699 await git(work, "push", "-q", dir, "main:main");
97100 calls = 0;
98101 most = 0;
102 // Hold every reading until both lists have answered. Left to the clock, a
103 // loaded process fires the budget timer late and the first readings finish
104 // inside it: those pulls then answer their fresh conflict, which is right,
105 // but not the stale answer this test is about (#17698).
106 let release!: () => void;
107 gate = new Promise<void>((r) => (release = r));
99108
100109 const t0 = performance.now();
101110 const [during, again] = await Promise.all([
@@ -103,12 +112,14 @@ test("50 pulls, a slow merge check, main moves: the list answers in under 1 s an
103112 pullMergeStates(items, { check: slow }),
104113 ]);
105114 const took = performance.now() - t0;
115 release();
116 gate = null;
106117 expect(took).toBeLessThan(1000);
107118 expect(took).toBeGreaterThanOrEqual(MERGE_BUDGET_MS - 5);
108119 // 50 readings at four at a time and 200 ms each is 2.6 s: most are unread,
109120 // and those answer their last reading (same head), never a blank.
110121 expect(during.every((m) => m !== null)).toBe(true);
111 expect(during.filter((m, i) => i < CLASH && m!.mergeable).length).toBeGreaterThan(0);
122 expect(during.every((m) => m!.mergeable && m!.conflicts.length === 0)).toBe(true);
112123 expect(again).toEqual(during);
113124
114125 await mergeReadingsSettled();

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs