Skip to content

Commit 8bf0a0b

Browse files
authored
Bound the margin layout wait so a stalled module fails the test, not the job (#154)
## Problem The review on #153 ([review](#153 (review))) raised this while that PR was in flight; it merged before the point was actioned, so the shape is on `main` now. `margins_laid_out` awaits the `/runtime/margin-layout.js` import inside `page.evaluate`, which `tests/CLAUDE.md` names as the unbounded case: "`page.evaluate` takes no timeout in any binding, so a promise awaited inside it — an animation's `finished`, a module's load, a listener's next call — is a wait nothing bounds. It does not fail in thirty seconds naming its test: it spends the job's whole step, and the share of the suite already handed to that worker never runs." That is the class #84 and #95 bound at eleven other sites; this helper was added after them and reintroduces it at three call sites — `test_render_pages.py` twice and `test_render_margin.py` once — all of them on the render suite's ordinary path. ## Solution Poll the import from the driver with `wait_for_function` against `render_checks.SERVED_TIMEOUT_MS`, the same patience the payload's own probes carry. The deadline moves to the driver side, which is the shape `tests/CLAUDE.md` prefers; the round trip count and the frame the layout runs in are unchanged. The docstring now says why the wait is bounded from outside, so the next reader does not have to re-derive it. ## Testing On this branch, rebased on `6d68a1b`: - `uv run pytest tests` — 740 passed, 6 skipped. That is the gate CI runs on this PR. - `uv run pytest tests/test_render_pages.py::test_a_left_sidebar_uses_the_margin_until_the_page_needs_it_back --run-nightly -n0` — passes. This is the test #153 fixed, and the one the helper was written for. - `uv run pytest tests/test_render_margin.py tests/test_render_pages.py --run-nightly -n2` — 62 passed, 2 failed. Both failures are pre-existing and untouched here (below). - `ruff check` and `ruff format --check` over the changed file pass. <details><summary>The two nightly failures, and why they are not this change</summary> `test_render_margin.py::test_g_addresses_the_page_map_prefix_in_its_announced_order` and `test_one_margin_item_owns_a_targets_controls_information_and_more_actions` both wait for `m\s*page-map items` on the key line and read `gm1–9page-map items` / `gm1–4page-map items` instead. I reran both at `-n0` with this diff stashed, on `6d68a1b` unmodified: they fail identically. They belong to `aa41f7a` ("Keep chord hints stable through progress"), which changed the chord row to carry the item count, and #153's body already named them on its own base. No open issue tracks them yet; the next `ci` on `main` should route them to `tend-ci-fix`. </details> --------- Co-authored-by: leaf-agent <[email protected]>
1 parent b4a5aeb commit 8bf0a0b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎tests/render_harness.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,10 +1354,21 @@ def margins_laid_out(page):
13541354
The pending frame is not a fact to wait a frame for (`tests/CLAUDE.md`, "a fixed
13551355
number of animation frames only guesses"), so the work is run instead of guessed at.
13561356
Whether the observer schedules it at all is `test_render_margin.py`'s subject, not
1357-
that of a test reading the layout it produces."""
1358-
page.evaluate(
1357+
that of a test reading the layout it produces.
1358+
1359+
The module load is awaited from the driver rather than inside `page.evaluate`, which
1360+
takes no timeout in any binding: a preview that stalls on the way out would hold the
1361+
worker for the rest of the job step instead of failing in thirty seconds naming its
1362+
test. `SERVED_TIMEOUT_MS` is the same patience the payload's own probes carry.
1363+
1364+
The `true` is load-bearing, not the comma operator's leftover: `wait_for_function`
1365+
awaits a promise the predicate returns, but a falsy resolution ends the wait rather
1366+
than polling again, so a predicate handing back the layout's own result would return
1367+
at once and prove nothing."""
1368+
page.wait_for_function(
13591369
"() => import('/runtime/margin-layout.js')"
1360-
".then(({layoutMarginRows}) => layoutMarginRows())"
1370+
".then(({layoutMarginRows}) => (layoutMarginRows(), true))",
1371+
timeout=render_checks_model.SERVED_TIMEOUT_MS,
13611372
)
13621373

13631374

0 commit comments

Comments
 (0)