Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 2.44 KB

File metadata and controls

45 lines (29 loc) · 2.44 KB

External PDF manifest (files.json) testing plan

Goal

Use the repo’s files.json plus its PDF tree (default relative path in pdf/sample_files_test.go as sampleFilesRoot) as the single source of truth for smoke-testing pdf.OpenFile / NumPages / first-page geometry.

How to run

  • Put the manifest and PDFs where the test constant points (root .gitignore may ignore references/; prepare locally or in CI).
  • From the module root:
go test ./pdf/... -run TestSampleFilesManifestAgainstReader -count=1
  • If files.json is missing, the test Skips (not a failure).

Current assertions (manifest-aligned)

For each files.json entry:

Condition Expectation
encrypted: true OpenFile returns pdf.ErrEncrypted
encrypted: false and not in skip map OpenFile succeeds; NumPages() equals pages; Page(0).MediaBox() exists
Missing file Skip

Known exceptions (not required to be “fully readable”)

path Note
017-unreadable-meta-data/unreadablemetadata.pdf Hybrid linearization + bad /Prev (into a NUL region). The reader stops invalid xref chains to avoid failing the whole file, but cannot rebuild the full object table from the first xref segment alone; many implementations still fail at xref repair or /Pages flattening. The test Skips this entry with a documented reason.

If xref rebuild / more robust incremental parsing is added later, remove this Skip first, then satisfy the assertions above.

Reader fix notes (017)

  • Issue: manifest startxref points to an xref near the file head; that trailer’s /Prev points into an all-0x00 region; continuing yields a bogus xref stream offset and errors.
  • Fix: in reader_xref.go, xrefSegmentLooksValid: if the offset region starts with NUL, treat the segment as invalid and end the xref chain (common handling for broken incremental pointers), so ErrXRef does not block other readable files.

Follow-ups (planned)

  1. Stronger checks: for encrypted: false samples with rich annotations, optionally assert AnnotDicts counts vs manifest annotations (must match manifest counting rules).
  2. CI: workflow step cloning the corpus next to sampleFilesRoot.
  3. Cross-check: optional second process using another toolkit to compare page counts (higher cost; secondary gate only).