Testing
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.
The three layers
Section titled “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 |
Standards
Section titled “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.
Stress
Section titled “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
Section titled “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
Section titled “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
Section titled “When a real page breaks Parsec”- Save the page locally. Don’t commit it.
- Shrink it to the smallest input that still fails:
Terminal window cargo run -p parsec-reduce -- page.html --check panic--checktakespanic,hang:MS,differs-from-html5ever, orcmd:COMMANDfor anything else. - Put the result in
crates/parsec-web/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-web --test regressionswrites the expected.treebeside it. - Fix the bug in the same pull request, so the fixture goes green.
Running it all
Section titled “Running it all”cargo test --workspace # standards, on your machinecargo run --release --manifest-path bench/Cargo.toml -- boss # the final bossscripts/conformance-gate.sh conformance/baseline.json target/conformance # after a run with CONFORMANCE_DIR setThe fuzz targets are listed in crates/*/fuzz/Cargo.toml; Contributing has the commands.