Skip to content

Commit 8b170ed

Browse files
committed
test(daemon): assert the prepare budget is wired, not that zero time passed
`prepareAppleRunner` spends one budget across the boot wait and the runner, so what reaches the runner is `--timeout` minus whatever readiness already used. The assertion demanded exactly 240000, which holds only when both `Date.now()` reads land in the same millisecond; CI caught it at 239999. Assert each budget carries the unspent remainder and never exceeds the request. Both bounds are live: forcing the remainder to 1 fails the lower bound, and re-spending the full budget fails the upper.
1 parent ea79a2d commit 8b170ed

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎src/daemon/session-lifecycle/internal/__tests__/session-open-url-prewarm.test.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,18 +604,28 @@ test('prepare ios-runner starts the XCTest runner on an explicit iOS selector',
604604
expect.objectContaining({ platform: 'apple', id: 'sim-1' }),
605605
expect.objectContaining({
606606
cleanStaleBundles: true,
607-
buildTimeoutMs: 240000,
608-
healthTimeoutMs: 240000,
609607
logPath: expect.stringMatching(/runner\.log$/),
610608
prepareDeadline: expect.objectContaining({
611609
elapsedMs: expect.any(Function),
612610
isExpired: expect.any(Function),
613611
remainingMs: expect.any(Function),
614612
}),
615613
requestId: 'prepare-request',
616-
startupTimeoutMs: 240000,
617614
}),
618615
);
616+
// `prepareAppleRunner` spends one budget across the boot wait and the runner, so what reaches
617+
// the runner is `--timeout` minus whatever readiness already used. Asserting the exact request
618+
// asserts that zero wall-clock time passed, which is an accident of scheduling rather than a
619+
// property of the system; the guarantee is that each budget is wired and never re-spent.
620+
const [, prepareOptions] = mockPrepareIosRunner.mock.calls[0]!;
621+
for (const field of ['buildTimeoutMs', 'healthTimeoutMs', 'startupTimeoutMs'] as const) {
622+
expect
623+
.soft(prepareOptions[field], `${field} carries the unspent remainder of --timeout`)
624+
.toBeGreaterThan(239_000);
625+
expect
626+
.soft(prepareOptions[field], `${field} never exceeds --timeout`)
627+
.toBeLessThanOrEqual(240_000);
628+
}
619629
if (response.ok) {
620630
expect(response.data).toMatchObject({
621631
action: 'ios-runner',

0 commit comments

Comments
 (0)