Site-wide crawl analysis that runs once when a crawl finishes, linear in URLs + links: - Indexability column (Indexable / Non-Indexable + reason), reading the X-Robots-Tag header as well as the robots meta tag - Duplicate title, meta description and H1 across indexable pages; multiple title / meta description / H1 tags per page - Redirect chains, loops and redirects to broken URLs, followed or not - Unique inlinks/outlinks and Link Score (internal PageRank, 0-100) - Per-page broken internal/external links and links to redirects - Canonicals pointing at non-indexable URLs, canonical chains, multiple and conflicting canonicals (HTML tags and Link headers) - Sitemap audit: orphan pages, non-indexable URLs in the sitemap, indexable pages missing from it Crawl comparison tab and /api/crawls/compare (JSON or CSV): new/removed URLs, status, indexability, title, meta, H1, canonical and word-count changes, and issues that appeared or were resolved. Hardening found by fuzzing: a malformed href, Location or sitemap <loc> no longer loses a page or the rest of the sitemap; UTF-8 headers decode correctly; a corrupt DB value can no longer empty a loaded crawl. Resumed crawls no longer save end-of-crawl issues twice, and linked_from is saved complete.
LibreCrawl tests
No test framework and no extra dependencies. Both files are plain scripts that run against the code already in this repo.
fixture_tests.py
Deterministic tests. Starts tiny HTTP servers on localhost and runs the crawler against them in-process, so nothing touches the internet.
python tests/fixture_tests.py
Prints a PASS/FAIL line per behaviour and exits non-zero if any fail. If ports
8911-8926 are taken locally, set FIXTURE_BASE_PORT to move the range.
Each test pins a bug that reached production once:
| Test | What breaks if it fails |
|---|---|
test_cross_domain_redirect |
A page redirecting off-site makes the crawler resolve that site's relative links against your domain, inventing internal 404s |
test_external_images |
Off-domain images get requested and listed even with external crawling off |
test_sitemap_discovery_is_async |
Sitemap probing blocks the start-crawl request, or the crawl finishes before discovery delivers its URLs |
test_max_urls_counts_pages_not_images |
Image rows consume the max-URL budget, so an image-heavy site crawls only a page or two |
test_event_ordering_under_polling |
The UI receives an update for a row it was never sent, or the same row twice |
test_duplicate_detection_is_linear |
A site of templated pages holds the crawl in "finishing up" for minutes and produces two duplicate issues per matching pair (700k rows for 1,000 pages), locking the database while they save |
test_export_formats_apply_to_every_data_type |
The format chosen in Settings is ignored for links/issues exports, or Excel silently produces CSV |
test_crawl_delay_is_honoured |
The crawl delay setting is ignored with JavaScript rendering off, so sites get hit as fast as concurrency allows |
test_list_mode_fetches_only_the_list |
List mode follows links, probes sitemaps, drops a listed URL, fetches a robots.txt-disallowed URL, or misses URLs on a second site |
test_custom_extraction |
CSS/XPath extractors return wrong values, break on pages without matches, lose their per-extractor export columns, or save with an invalid selector |
test_site_wide_analysis |
Indexability ignores X-Robots-Tag; duplicate title/meta/H1, redirect chains and loops, broken-link sources, canonical chains, inlinks, Link Score or the sitemap/orphan audit go wrong; analysis patches reach the UI before their rows |
test_crawl_analysis_scales_linearly |
The end-of-crawl analysis turns quadratic on templated sites and holds a large crawl in "finishing up" |
test_hostile_input_regressions |
One malformed href, Location or sitemap <loc> loses a whole page or the rest of the sitemap; 204 counts as indexable; a javascript: canonical marks a page canonicalised; equally linked pages score 0; a corrupt DB value empties a loaded crawl |
test_canonicals_and_titles |
Repeated or conflicting canonicals (tags or Link headers) go unreported, conflicting ones still mark the page canonicalised, a header-only canonical is missed, or titles inside SVG/<object>/<iframe> count as page titles |
test_analysis_persists_and_crawls_compare |
Analysis fields or the final linked_from are lost on reload, crawl comparison misreports changes or leaks another user's crawls, or a resumed crawl saves its end-of-crawl issues twice |
crawl_harness.py
End-to-end test against a real site. Start LibreCrawl first, then point the
harness at a URL. It polls /api/crawl_status using the same event protocol as
the browser and accumulates state the same way
web/static/js/incremental_poller.js does.
python main.py --local # in one terminal
python tests/crawl_harness.py https://example.com/ --max-urls 150
Useful flags: --js (JavaScript rendering), --images, --external,
--pause-test (also verifies pause actually halts work and resume continues),
--delay and --max-urls to stay polite on sites you do not own, and --base
to drive an instance on another host or port.
It verifies, on every run:
- no duplicate
url/linkevents, and no update for a row that was never sent - the client's accumulated state matches the server's full snapshot exactly
- mutations reach the client, specifically link status backfills and the
linked_fromvalues filled in at the end of a crawl - rows stay in scope: nothing off-domain unless
--externalis set - the counter never reports fewer crawled URLs than the rows already sent
- streaming exports contain exactly one row per URL, link and issue
- reloading the crawl from SQLite flips the epoch, replays every row, and matches what was crawled
On failure it prints the poll history (sequence numbers, event counts, epoch changes) so the violation can be explained rather than just reported.