Skip to content

test(chartgen): assert the headroom against the budget, not the render - #178

Merged
zannis merged 1 commit into
mainfrom
zannis/test/caption-headroom-vs-canvas-growth
Sep 9, 2026
Merged

test(chartgen): assert the headroom against the budget, not the render#178
zannis merged 1 commit into
mainfrom
zannis/test/caption-headroom-vs-canvas-growth

Conversation

@zannis

@zannis zannis commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Two commits that never conflicted, and the later one dissolved the earlier one's property

#174 added a test asserting the parallel-vs-sequenced 64 KiB caption's headroom rather than its wording, so that it fails when the budget is next approached rather than when a sentence is reworded.

It does not do that on merged main — because of a sibling, not because of anything wrong with the test as written.

What happened

commit what it did
4b69b80 (#165) the fix: bought back two caption lines, headroom 3 (2 with redeliveries) against a hard budget of 21
52e27b1 (#176) a caption up to MAX_CAPTION_GROWTH_LINES (8) over budget grows the canvas instead of refusing
a36b614 (#174) the headroom test, branched before #176, merged after it

#174 proved its margin by rendering the six-backend slice with two further notes added and requiring the render to succeed. Against a hard budget that is decisive. Against a soft one it is not: the render now succeeds whether the headroom exists or not.

The two never touched the same lines, so nothing conflicted and CI stayed green on both.

Measured, not argued

On merged main (eb9a7fa), one unconditional caption line planted in the parallel-vs-sequenced note set:

merged #174 this PR
headroom test under the planted line PASS — margin gone, undetected FAIL656 != 640
the three wording tests PASS PASS
committed-SVG byte-compare FAIL (expected: the control edits a caption) FAIL (same)

#174's own control run reported this test failing with frame()'s refusal message. That was measured on the branch, which predated #176 — a hard budget still refused. The soft budget absorbs it silently.

The change

Assert the canvas height, not the Ok. Both the six-backend redelivery fixture and its two-further-notes variant must seat on the base HEIGHT canvas, leaving the growth allowance unspent — spending it is the budget being gone rather than headroom.

That restores the asymmetry intended: it fails when the budget is approached, whatever spends it, and while the margin still exists.

Also folds the growth test's inline height parsing into the shared canvas_height helper — same parse, previously duplicated.

Gates

  • cargo nextest run --no-default-features343 passed, including the committed-SVG byte-compare
  • cargo fmt -- --check, cargo clippy --no-default-features --all-targets -- -D warnings — clean
  • Tests only. No production change, so no SVG churn.

Depends-on: none — the implementation this asserts against (#165) and the growth allowance that weakened the assertion (#176) are both already on main, as is the test this replaces (#174).

`52e27b1` landed the caption growth allowance between the headroom test's
branch point and its merge, so the two commits never conflicted textually
while the later one dissolved the property the earlier one asserted.

`the_tightest_slice_keeps_two_caption_lines_spare_at_six_backends` proved
its margin by rendering the six-backend slice with two further notes and
requiring the render to succeed. That was decisive against a hard budget.
It is not against a soft one: a caption up to MAX_CAPTION_GROWTH_LINES (8)
over budget now grows the canvas instead of refusing, so the render
succeeds whether the headroom exists or not.

Measured on merged `main`: planting one unconditional caption line in the
`parallel-vs-sequenced` note set leaves the test green. The margin it
reports is spent and it cannot tell.

Assert the canvas height instead. Two further notes must seat on the base
`HEIGHT` canvas, leaving the growth allowance unspent — spending it is the
budget being gone, not headroom. Under the same planted line the test now
fails (656 != 640) while all three wording tests still pass, which is the
asymmetry the criterion asked for: it fails when the budget is approached,
not when a sentence is reworded.

Tests only; no production change and no SVG churn.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shove-docs 87adb81 Commit Preview URL

Branch Preview URL
Sep 09 2026, 08:38 AM

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zannis
zannis merged commit 7c3c34a into main Sep 9, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant