Skip to content

Add automated conformance testing against html5lib-tests #1

Description

@casoon

Problem

Test coverage today is hand-written unit tests (in src/tree_builder.rs, src/tokenizer.rs) and end-to-end tests (src/lib.rs) targeting specific spec sections and scenarios ported from html-conform's own test matrix. That's solid for verifying individual algorithms, but there's no automated check against the html5lib-tests / WHATWG shared conformance corpus that every serious HTML5 parser (html5ever, html.parser, Validator.nu, browsers) is measured against. For a from-scratch, spec-transcribed parser, this is the single most valuable remaining quality signal — it would catch transcription mistakes and edge cases no amount of hand-written tests will reliably find.

Solution path

  1. Vendor (or fetch via an xtask script, matching the existing xtask/gen-entities.py pattern) the tree-construction/*.dat files from https://github.com/html5lib/html5lib-tests — a well-known, widely-used format:
    • #data — input HTML.
    • #errors — expected parse errors (not applicable here, this crate has no diagnostics; skip this section).
    • #document — expected resulting tree, as an indented text dump.
    • Some files also have #document-fragment (fragment-parsing cases) and #script-off/#script-on — since this crate has no fragment parsing and always treats scripting as disabled, only the plain #document full-document cases apply. Document which sections/files are skipped and why (matching this project's existing "no silent exclusions" practice).
  2. Write a small parser for the .dat format (it's simple — blank-line-separated sections) and a serializer that converts this crate's Document tree into the same indentation-based dump format html5lib-tests uses, so expected vs. actual can be compared as plain strings.
  3. Add this as an integration test (e.g. tests/html5lib_conformance.rs) that runs each case through parse() and diffs the dump. Start with the simpler files (tests1.dat, tests2.dat) before the harder ones (tables01.dat, adoption01.dat; skip foreign-fragment.dat, it's fragment-only).
  4. Expect (and explicitly track — e.g. a # known-failing allowlist, or #[ignore] with a documented reason) a nonzero number of failures at first, from the frameset/template gaps (see README overstates tree-construction completeness (frameset modes, <template> simplification undocumented) html5-parser#1) and any real transcription bugs the corpus surfaces. Fix what's fixable, document what's out of scope.
  5. Wire into CI (.github/workflows/ci.yml) once the pass rate is stable, so future regressions get caught automatically.

This is a substantial task — plan to work through it in stages (vendor + harness first, then work through failures file by file), not as a single PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions