Files
deepseek-harness/scripts/fixtures/lane-test-budget.fixture.ts
Tianyi Cui 3e38e2118c test(vitest): make the lane-budget regression load-independent and own its resources
The fixture's poll case counts attempts instead of reading a clock, so a host
stall cannot turn a budget-ended poll into a pass; the control case reads the
poll's reported duration, which the 1000 ms default bounds from below. The
spawning spec acquires its temporary config in beforeAll, bounds the child
with a timeout and asserts no signal ended it, and counts the polled values it
inspects. CoverageTestTimeoutOptions is Vitest's own TestUserConfig members;
the rule's reach has one home in its JSDoc, which the config, gate, spec, and
note comments reference.
2026-09-28 14:18:03 +08:00

33 lines
1.2 KiB
TypeScript

/**
* Waits that end only through the lane budget in force. Runs only inside the
* Vitest child that scripts/lane-test-budget.spec.ts spawns.
*/
import { beforeEach, describe, expect, it } from 'vitest'
const sleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms))
describe('lane test budget fixture', () => {
it('per-test budget', async () => {
await sleep(600)
})
// The predicate counts attempts instead of reading a clock, so a host stall
// cannot turn a budget-ended poll into a pass: a 10 ms interval fits at most
// ~20 attempts into a 200 ms budget and ~100 into Vitest's 1000 ms default,
// both far below the target, and the case's own budget stays above both so
// the poll budget is what ends the assertion. The reported duration is then
// the poll budget (or longer under load), which the spawning spec reads.
it('expect.poll budget', { timeout: 5_000 }, async () => {
let attempts = 0
await expect.poll(() => { attempts += 1; return attempts }, { interval: 10 }).toBeGreaterThan(10_000)
})
describe('hook budget', () => {
beforeEach(async () => {
await sleep(600)
})
it('runs after the hook', () => {})
})
})