Testing
scripts/fetch-test-pdfs.sh # download the test papers, once
cargo test --release
-
Unit tests and end-to-end tests on small generated PDFs.
-
8 real arXiv papers (
tests/real_papers.rs): per paper, the title, tables rebuilt, paragraphs broken mid-sentence, words still hyphenated, characters left in thehard-95background and formulas rebuilt as MathML. The limits are the current results: better passes, worse fails; tighten them after an improvement (KAKEMONO_PRINT_METRICS=1 cargo test --release --test real_papers -- --nocapture). -
Editable JSON: on every paper, an unedited file changes nothing and edited text comes back exactly as written; edited text reaches every output with its formulas and links.
-
Snapshots: a hash of each mode’s HTML, of the Word, Markdown, LaTeX, Typst and EPUB documents, of the editable JSON, of the chunks and of the
--jsondocument per paper, intests/data/snapshots/. When the output changes on purpose, update them and commit them with the code:KAKEMONO_UPDATE_SNAPSHOTS=1 cargo test --release --test real_papers. -
Word input (
tests/word.rs):tests/data/word/sample.docx, written by pandoc fromsample.md,sample.doc, the same saved by LibreOffice, andlists.docx(nested lists) are read and written to every format (snapshot intests/data/snapshots/word-sample.txt); the LIGO paper goes through a round trip PDF → Word → kakemono. To make the samples again:cd tests/data/word && pandoc sample.md -o sample.docx && soffice --headless --convert-to doc sample.docx. -
Excel input (
tests/excel.rs):tests/data/excel/sample.xlsx, saved by LibreOffice from the hand-writtensample.fods, andcharts.xlsx(charts, pictures), written bytests/data/excel/make-chart-xlsx.py, are read and written to every format (snapshot intests/data/snapshots/excel-sample.txt). To make the sample again:soffice --headless --convert-to xlsx --outdir tests/data/excel tests/data/excel/sample.fods. -
PowerPoint input (
tests/powerpoint.rs):tests/data/powerpoint/sample.pptx, written bypython3 -I tests/data/powerpoint/make-sample-pptx.py(the standard library only), is read and written to every format (snapshot intests/data/snapshots/powerpoint-sample.txt); small decks built in the test cover titles in text boxes, title slides, sections, furniture, reading order, notes and hostile packages;src/layout/slides/tests.rscovers the pages. -
EPUB input (
tests/epub.rs):tests/data/epub/sample.epub, written by pandoc from the sametests/data/word/sample.md, is read like the Word sample and written to every format (snapshot intests/data/snapshots/epub-sample.txt); small books built in the test cover style sheets, lists, merged cells, notes and pictures, and the LIGO paper goes through a round trip PDF → EPUB → kakemono. To make the sample again:cd tests/data/word && pandoc sample.md --mathml -o ../epub/sample.epub. -
Web pages (
tests/html.rs):tests/data/html/sample.html, written by pandoc from the sametests/data/word/sample.md, reads like the Word sample and the EPUB sample and is written to every format (snapshot intests/data/snapshots/html-sample.txt); small pages built in the test cover clutter, lazy pictures, links, Wikipedia’s and LaTeXML’s notes and encodings, and a page at an address is read with its pictures fetched by the test. Real pages (tests/web_pages.rs: Wikipedia in English and Vietnamese, arXiv HTML papers, a news article, a research blog, documentation):scripts/fetch-test-pages.shdownloads those oftests/data/web-pages.tsv(not committed); the test checks the title, text that must be there, clutter that must not, and lower bounds on words and notes. To make the sample again:cd tests/data/word && pandoc -s --mathml sample.md -o ../html/sample.html, then point its picture to../word/curve.png. -
Web benchmark (
scripts/web-bench/): some 330 pages, 181 of them with a ground truth (the Scrapinghub article extraction benchmark), scored as that benchmark scores article extraction and against trafilatura and readability, written to every output, and gathered in review PDFs (the page on its site beside kakemono’s output) to look through. -
Word layout fidelity (CI job “Word layout fidelity”):
scripts/fetch-word-corpus.shdownloads the Word documents oftests/data/word-corpus.tsvwith the PDF Word made of each (public documents: gov.uk, data.gov.uk, data.gov.au, public GitHub repositories; not committed);scripts/word-fidelity.pylays each out and compares it with Word’s PDF line by line (scripts/compare-layout.py): the share of lines broken at the same words, and of documents with the same page count. The job fails below its minimums. Pairs left out, and why, are intests/data/word-corpus-excluded.tsv. -
PowerPoint layout fidelity (CI job “PowerPoint layout fidelity”):
scripts/fetch-powerpoint-corpus.shdownloads the 113 public decks oftests/data/powerpoint-corpus.tsv(not committed), with the PDF PowerPoint made of the five that publish one;scripts/word-fidelity.py --corpus tests/data/powerpoint-corpus --name PowerPointcompares our pages with PowerPoint’s as for Word.python3 scripts/word-crash-test.py tests/data/powerpoint-corpuswrites every output of every deck and reports panics and timeouts. -
Word layout fixtures (
tests/word_layout.rs): seven documents of that corpus, chosen for what they hold (columns, text boxes, floating shapes, frames, EMF pictures, rows of exact height), are laid out and compared with Word’s PDFs on every CI run, with a minimum per document; they are downloaded first (scripts/fetch-word-corpus.sh 8 $(cat tests/data/word-layout-fixtures.txt)) and skipped when missing. -
Crash test:
scripts/word-crash-test.py DIR...converts every Word file found to every output and reports panics and timeouts (run on 4,300 public Word files: none).
Only the LIGO paper (CC BY 4.0) is in the repository; tests skip papers that are not downloaded.
The JavaScript is checked in a browser (needs playwright):
node tests/browser/check-friendly.js out/*.friendly.html
node tests/browser/check-hard95.js out/*.hard-95.html
node tests/browser/check-stable.js out/*.medium.html out/*.friendly.html
The Python package is tested with pytest (needs maturin):
cd python && python -m venv .venv && . .venv/bin/activate
pip install maturin pytest && maturin develop --release && pytest tests
CI runs cargo fmt, cargo clippy, the tests, the browser checks and the Python tests (with
wheels built for every platform) on every pull request.