Skip to content

Run the font tests as layers in layer mode - #95

Merged
bobsingor merged 1 commit into
embedpdf/mainfrom
embedpdf/fix/font-tests-layer-mode
Nov 1, 2026
Merged

bobsingor merged 1 commit into
embedpdf/mainfrom
embedpdf/fix/font-tests-layer-mode

Conversation

@bobsingor

Copy link
Copy Markdown
Contributor

Follow-up to #93. Layer mode (EPDF_EMBEDDER_LAYER_MODE=1) only made layers of files a test opens with OpenDocument(). Most font tests build their PDFs in memory or start from CreateEmptyDocument(), so they never ran on a layer with the read-only check and the layer DCHECKs on.

What changes

  • Loaders that go through layer mode:
    • EmbedderTest::OpenDocumentFromMemory() opens bytes the way OpenDocument() opens a file;
    • embedpdf_test::LoadMemDocumentForTest() with ScopedTestDocument does the same for a document a test keeps itself, and reports what it left in the layer when it closes;
    • EmptyPdf() replaces CreateEmptyDocument() for tests that write into a new document;
    • LayerFixture::SaveDelta() saves a layer's changes for Reopen().
  • Tests moved onto them:
    • the font tests (APlainDocumentIsWalkedWholeEachTime stays plain on purpose);
    • the two /ActualText tests;
    • the two rich-text last-resort tests.
  • Two new layer tests:
    • AFontWrittenOnALayerReadsTheSameReopened: a font written on a layer, saved, then reopened from its delta lists, serves and resolves the same, and reading it copies nothing into the layer.
    • AWriteToAFontsWidthsGivesItANewDisplayProgram: a write to an existing font's /Widths shows a new display program in a list during the write; an abort brings the old one back and a commit keeps the new one.
  • Fix in CPDF_DocumentFonts::Forget: a display program that only a changed font dictionary read stayed fetchable by its old hash. It is now dropped, so the hash finds nothing.
  • Test fix: ExpectDisplayProgramDrawsTheKeptFont read the font dictionary through GetMutableRoot(), which copied the catalog into the layer. It now reads const, as the runtime's read path does.
  • Writers list: the 14 tests that write on purpose are recorded in testing/embedpdf_layer_mode_writers.txt, including EPDFFormEmbedderTest.NewFieldAppearanceIsAFormXObject from Read, write and draw with a document's own fonts #93.
  • Ledger: the layer-mode rule now says how an in-memory test document gets into layer mode.

Testing (macOS arm64, debug)

  • 29 font, /ActualText and last-resort tests pass on plain documents.
  • run_layer_mode.py over the 128 font-related tests: all pass, and every read-only font test leaves 0 objects in its layer.
  • Full run_layer_mode.py over 1740 tests: no new layer-only failures.
    • Every test that fails only in layer mode matches testing/embedpdf_layer_mode_expectations.txt.
    • The one error is EPDFSignatureEmbedderTest.SignEncryptedDocument, which is local-only: its fixture is untracked, so the test skips on CI.
  • Plain run: the same 30 known macOS pixel failures as on embedpdf/main.
  • pdfium_unittests: 1312 pass.
  • check-fork-tags.py --strict and check-c-api.py pass.

The Linux Docker suites and layer mode run in CI.

Layer mode only made layers of files a test opens, so most font tests, which build their PDFs in memory, never ran on a layer. EmbedderTest::OpenDocumentFromMemory() and embedpdf_test::LoadMemDocumentForTest() take in-memory documents through the same path, and the font, ActualText and last-resort tests use them. New layer tests cover a font written, saved and reopened over its base, and a write to a font's widths. A display program only a changed font dictionary read is now forgotten, so its hash finds nothing.
@bobsingor
bobsingor merged commit e13afe9 into embedpdf/main Nov 1, 2026
1 check passed
@bobsingor
bobsingor deleted the embedpdf/fix/font-tests-layer-mode branch November 1, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant