Skip to content

Testing

James Conway edited this page Nov 22, 2026 · 2 revisions

Parsec is tested three ways, and each proves something the others can't. The public suites say it's right by the specs. The stress tests say it's fast and stays up when a page is built to knock it over. The real web says it's right on the pages people actually parse, which no spec suite covers.

On this page: The three layers · Standards · Stress · The real web · Release gates · When a real page breaks Parsec · Running it all

The three layers

Layer What runs What it proves Where the results are
Standards html5lib, web-platform-tests, test262, the W3C XML suite, css-parsing-tests, Unicode's normalization tests Correct against the specs Conformance, and every CI run's summary
Stress bench/ against Lexbor and html5ever, the final boss, fuzzing Speed, memory, and staying up under hostile input Benchmarks, Limits and hostile input
The real web Netweir crawling a pinned list of production sites through Parsec Correct and reliable on real pages Real-world benchmarks
flowchart LR
  pr["Pull request"] --> std["Standards<br/>cargo test, every OS"]
  pr --> stress["Stress<br/>final boss smoke, fuzz"]
  web["Netweir's weekly crawl<br/>production sites"] -->|"a page breaks Parsec"| reduce["parsec-reduce<br/>smallest failing input"]
  reduce --> fixture["tests/regressions/<br/>a test for good"]
  fixture --> std
  std --> gate{"Release gates"}
  stress --> gate
  gate -->|"all pass"| rel(["Release"])
Loading

Standards

Every suite runs in cargo test on Linux, macOS and Windows for every pull request, and writes its counts into the run's summary. Conformance has each suite's data, its pinned commit and its counts.

Note

A count only means something if it can't quietly drop. The release gates compare every count with the last release's.

Stress

  • Benchmarks. bench/ builds Lexbor from a pinned release and runs it, html5ever and Parsec on the same bytes in one process. The Benchmarks page has the method, the machine and the numbers.
  • The final boss. 1,000 pages built from a seed: broken fragments, re-encoded pages and 10 to 30 MB giants. CI runs a 300-page version on every pull request, failing on a crash or a hang.
  • Fuzzing. Every parser has a cargo-fuzz target, run nightly, with runtime assertions on in debug builds.

The real web

Netweir, the crawling framework Parsec's HTML parser came from, runs a pinned list of about 2,700 production URLs through Parsec and through html5ever every Monday (a 300-URL sample in CI; the full list locally). It reports panics, hangs and any page where the two trees differ. The list mixes home pages from the Tranco top sites with hand-picked inner pages: Wikipedia in 33 languages, docs, news, forums, shops, WordPress, server-rendered framework sites, government sites and legacy-encoded pages.

Only the URLs are published, never the pages: they belong to the sites. The Real-world benchmarks page has the first run's results and how to reproduce it.

Release gates

A release can't publish anything until three gates pass, in release.yml's gates job:

Gate Fails when
Conformance Any suite passes fewer cases or fails more than in conformance/baseline.json, the last release's counts, or a suite's counts are missing or unreadable
Final boss Any of the 1,000 pages crashes, hangs, or builds a different number of elements than html5ever does
Fuzzing Five minutes on every fuzz target finds anything

Speed is checked by hand, because CI runners are too noisy to time on: before a release, the bench runs at low load against the previous tag, and any slowdown over 5% is explained in the release notes. Releasing has the steps. The baseline only changes in a release pull request.

When a real page breaks Parsec

  1. Save the page locally. Don't commit it.
  2. Shrink it to the smallest input that still fails:
    cargo run -p parsec-reduce -- page.html --check panic
    --check takes panic, hang:MS, differs-from-html5ever, or cmd:COMMAND for anything else.
  3. Put the result in crates/parsec-html/tests/regressions/<short-name>.html, starting with <!-- site: URL; date: YYYY-MM-DD; failed: what went wrong; issue: #N -->. If the tree matters, BLESS_REGRESSIONS=1 cargo test -p parsec-html --test regressions writes the expected .tree beside it.
  4. Fix the bug in the same pull request, so the fixture goes green.

Important

Reduced inputs only, never whole pages. A few lines of tags reproduce almost every parser bug, and they're ours to publish; the page isn't.

Running it all

cargo test --workspace                                         # standards, on your machine
cargo run --release --manifest-path bench/Cargo.toml -- boss   # the final boss
scripts/conformance-gate.sh conformance/baseline.json target/conformance   # after a run with CONFORMANCE_DIR set

The fuzz targets are listed in crates/*/fuzz/Cargo.toml; Contributing has the commands.

Clone this wiki locally