Repository navigation
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.
On this page: The three layers · Standards · Stress · The real web · Release gates · When a real page breaks Parsec · Running it all
| 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"])
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.
-
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.
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.
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.
- Save the page locally. Don't commit it.
- Shrink it to the smallest input that still fails:
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-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 regressionswrites the expected.treebeside it. - 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.
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 setThe fuzz targets are listed in crates/*/fuzz/Cargo.toml; Contributing has the commands.
Parsec is the parsing foundation for the web, in Rust. It's Apache-2.0, 0.3.0 is out, and these pages describe main. Found something wrong here? Open an issue or ask in Discussions.
Repository · Issues · Discussions · Roadmap · Security policy · Licence