test: run html5lib-tests entity fixtures against the decoders - #2272
test: run html5lib-tests entity fixtures against the decoders#2272fb55 wants to merge 3 commits into
Conversation
Vendor the WHATWG html5lib-tests suite as a git submodule at test/fixtures/html5lib-tests and run its tokenizer entity fixtures (entities, namedEntities, numericEntities, pendingSpecChanges) against decodeHTML, decodeHTMLAttribute, and a one-character-per-chunk streaming EntityDecoder. A mechanical filter (documented in the spec) includes Data-state tests with Character-only output and the fixtures' attribute-value template tests; 4626 of 4627 fixtures are included, all passing. Parse-error assertions are ignored, as this library does not emit tokenizer errors. If the submodule is not initialized, the suite fails hard in CI and skips with a warning locally.
The html5lib-tests fixtures live in a submodule; without it the fixture suite fails hard when CI is set.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds a conformance-oriented test harness that runs the upstream WHATWG html5lib-tests tokenizer entity fixtures against both decoding implementations in this repo (direct trie-walk APIs and the streaming EntityDecoder state machine), with CI configured to fetch the fixtures via a git submodule.
Changes:
- Add
src/html5lib.spec.tsto load/token-filter html5lib tokenizer fixtures and assert results againstdecodeHTML/decodeHTMLAttributeand a char-by-char streaming decoder. - Add html5lib-tests as a git submodule at
test/fixtures/html5lib-tests. - Update CI checkout to fetch submodules and add Dependabot updates for the submodule.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/html5lib.spec.ts |
New vitest spec that filters and runs html5lib tokenizer entity fixtures against both direct and streaming decoder paths. |
.gitmodules |
Registers test/fixtures/html5lib-tests as a git submodule pointing to the upstream repo. |
.github/workflows/nodejs-test.yml |
Ensures the test job checks out submodules so fixtures are present in CI. |
.github/dependabot.yml |
Adds gitsubmodule ecosystem updates so fixture updates arrive automatically. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What this does
Vendors the WHATWG html5lib-tests suite as a git submodule at
test/fixtures/html5lib-tests(pinned to upstream224991e) and runs its tokenizer entity fixtures against this package's decoders in vitest (src/html5lib.spec.ts). The last few real bugs here were HTML-spec-conformance bugs (#2208 attribute-mode legacy entities, #2262 streaming over-consume); these fixtures pin spec behavior permanently and update themselves.Each included fixture is asserted against both decode paths:
decodeHTML/decodeHTMLAttribute(the direct trie walk), andEntityDecoderfed one character per chunk (the state machine htmlparser2 uses — a genuinely separate code path).Counts (at html5lib-tests
224991e)entities.testnamedEntities.testnumericEntities.testpendingSpecChanges.testAll 4626 included fixtures pass on both paths. No known-failures list is needed — no conformance divergences were found.
Filter rationale (mechanical, documented at the top of the spec)
The fixtures drive a full tokenizer; this library only decodes character references. Included are:
initialStatesbeyondData state, nolastStartTag) whose output is Character tokens only and whose input contains no<(needs tag-context modelling) and no\r(needs input-stream preprocessing) → concatenated character data must equaldecodeHTML(input).<h a=…>start tag with a singleaattribute (the suite's fixed template for attribute entity tests) → expected attribute value must equaldecodeHTMLAttributeon the extracted raw value.The single excluded test (
pendingSpecChanges.test) emits a Comment token.doubleEscapedis handled;errorsarrays are ignored — this library doesn't emit tokenizer parse errors (documented limitation in the spec header).A guard test asserts ≥4000 fixtures survive the filter, so a future submodule update can't silently filter everything away.
Missing-submodule behavior
CIenv set): the spec fails hard withhtml5lib-tests fixtures are missing. Run \git submodule update --init` to fetch them.` — a conformance suite must not silently pass in CI.--recurse-submodules): graceful skip with aconsole.warncarrying the same instruction, sonpm teststill works out of the box.Auto-updates & CI
.github/dependabot.ymlgains agitsubmoduleecosystem entry (same daily schedule as the existing entries), so upstream fixture changes arrive as regular dependabot PRs — and a fixture update that breaks conformance fails that PR's CI, which is the point..github/workflows/nodejs-test.yml: the test job's checkout getssubmodules: true(only the test job needs it; lint/build don't). Note: this overlaps with the in-flightci/node-versionsbranch which touches the same workflow — the diff here is kept to exactly the twosubmoduleslines to minimize the conflict.Packaging & licensing
npm packverified: neither the spec (excluded via!**/*.spec.ts) nor the submodule (test/isn't infiles) is published.