Modern Apps git

← Modern-Apps.git

pdf: run reference-diff tests by default (#tests)

Commit
b0062bd35784290ca4e6ba4ac0c16c35e0e3cc2b
Author
Vayun Mathur <[email protected]>
When
2026-11-15 17:45 UTC (20 days ago)
Parents
5e5665e
The reference-diff suite (25 tests in reference_diff_tests_part2..7)
compares this crate's rasteriser against the independent hayro
renderer on documents built in-test. It was #[ignore]d following the
perf harness, so the normal suite never ran it, even though the
assertions need no stored reference images, no fixtures and no
network. All 25 pass in under a second, so they now run by default:
an independent-renderer differential is a correctness check, not a
measurement, and ignoring it only hid regressions.

Also un-ignore
font_cache_distinguishes_documents_whose_font_dicts_are_equal_but_indirect_targets_differ.
It originally failed (the second document was served the first
document's font metrics through shallow /Widths dictionary
equality) and was ignored as unreachable by any caller. The cache
now keys on font_identity, which resolves through the dictionary's
indirect references, so the documents no longer collide and the
test passes; running it by default pins that identity. Its doc
comment is updated from ignored-and-failing to regression guard.

Left ignored, deliberately: the 18 perf_* measurement harnesses
(pdf_render ignored 46 -> 20), the issue321_fill_colors fixture
debug helper, and the bisect_nesting_depth stack-overflow probe.

Verified: cargo test --profile fast -p pdf_render (default run)
597 passed, 0 failed, 20 ignored (was 571 passed, 46 ignored).

Diff

pdf/src/main/rust/src/differential_tests_part2.rs
diff --git a/pdf/src/main/rust/src/differential_tests_part2.rs b/pdf/src/main/rust/src/differential_tests_part2.rsindex a9a913a21a..8b65df1272 100644--- a/pdf/src/main/rust/src/differential_tests_part2.rs+++ b/pdf/src/main/rust/src/differential_tests_part2.rs@@ -18,20 +18,18 @@ /// slightly stronger than what shallow dictionary equality actually buys, and /// that gap should be written down rather than rediscovered. ///-/// IGNORED, and it FAILS when run, exactly as its predecessor did before the fix.+/// This originally FAILED exactly as its predecessor did before the fix. /// Verified 2026-08-29 against the `ObjectId` + stored-dictionary key: the /// 900/1000 document was served the 500/1000 document's metrics, giving an /// advance of 10.0 (= 500/1000 x 20pt) where 18.0 (= 900/1000 x 20pt) is correct,-/// and glyph origins at 10/20/30 instead of 10/28/46. Ignored because no caller-/// can reach it, NOT because the finding is doubtful. Routed to `residuals`.+/// and glyph origins at 10/20/30 instead of 10/28/46. It was then ignored+/// because no caller could reach it, NOT because the finding was doubtful. ///-/// A deep fix does not need a deep dictionary compare: including the resolved-/// generation of each indirect target would cost as much as the parse being-/// cached. Cheaper is to scope the cache to a document identity that cannot be-/// recycled — a monotonic id minted per `Document` load — which closes the class-/// rather than another instance of it.-#[ignore = "latent, not live: stale hit through shallow /Widths dictionary equality, unreachable \-            by any current caller; see the doc comment and the note routed to residuals"]+/// The cache now keys on `font_identity`, which resolves through the+/// dictionary's indirect references, so the two documents no longer collide+/// and this test passes. It runs in the default suite as the regression+/// guard for that identity: a key that goes back to shallow dictionary+/// equality turns it red again. #[test] fn font_cache_distinguishes_documents_whose_font_dicts_are_equal_but_indirect_targets_differ() {     let build = |width: i64| {
pdf/src/main/rust/src/reference_diff_tests.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests.rs b/pdf/src/main/rust/src/reference_diff_tests.rsindex 83bf0b7f98..729f10d611 100644--- a/pdf/src/main/rust/src/reference_diff_tests.rs+++ b/pdf/src/main/rust/src/reference_diff_tests.rs@@ -198,11 +198,12 @@ //! //! # Running //!-//! Every test here is `#[ignore]`d, following `perf_tests.rs`, so the normal-//! suite is unchanged:+//! Every test here runs in the normal suite (they compare against the+//! independent `hayro` renderer, so the assertions stay meaningful without+//! any stored reference images): //! //! ```text-//! cargo test -p pdf_render reference_diff -- --ignored --nocapture+//! cargo test -p pdf_render reference_diff -- --nocapture //! ```  use crate::*;
pdf/src/main/rust/src/reference_diff_tests_part2.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part2.rs b/pdf/src/main/rust/src/reference_diff_tests_part2.rsindex 0fce6af0c4..b9618305dc 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part2.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part2.rs@@ -357,7 +357,6 @@ fn n(v: f64) -> Object { /// [`DIFF_BUDGET`] — the flagged fraction printed here is the metric's noise /// floor for a page that is by construction identical. #[test]-#[ignore] fn refdiff_solid_fills_calibrate_the_metric() {     let ops = vec![         op("rg", vec![n(0.9), n(0.1), n(0.1)]),
pdf/src/main/rust/src/reference_diff_tests_part3.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part3.rs b/pdf/src/main/rust/src/reference_diff_tests_part3.rsindex f0f2a8a281..f8a25b2c8e 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part3.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part3.rs@@ -16,7 +16,6 @@ /// future change to `cmyk_to_argb` shows up here as a change in the printed /// deltas. #[test]-#[ignore] fn refdiff_devicecmyk_diverges_because_the_reference_is_colour_managed() {     let patches: [[f64; 4]; 6] = [         [0.0, 1.0, 1.0, 0.0],@@ -69,7 +68,6 @@ fn refdiff_devicecmyk_diverges_because_the_reference_is_colour_managed() { /// Nonzero vs even-odd on a self-intersecting star: the classic place to get /// §8.5.3.3.2 backwards and never notice, because both rules look plausible. #[test]-#[ignore] fn refdiff_winding_rules_on_a_self_intersecting_star() {     let star = |close: &str| {         let pts = [(100.0, 190.0), (145.0, 55.0), (30.0, 140.0), (170.0, 140.0), (55.0, 55.0)];@@ -92,7 +90,6 @@ fn refdiff_winding_rules_on_a_self_intersecting_star() { /// tint→alternate direction backwards, or the Indexed lookup stride wrong, is a /// misreading no self-referential test can catch. #[test]-#[ignore] fn refdiff_indexed_and_separation_colour() {     let mut doc = Document::with_version("1.7");     // Indexed palette: 3 entries of DeviceRGB.@@ -174,7 +171,6 @@ fn refdiff_indexed_and_separation_colour() { /// highest-value entry in the corpus: `functions.rs` is 58 kB of formula, every /// line of it verified only against our own reading of §7.10. #[test]-#[ignore] fn refdiff_all_four_function_types_via_separation() {     let mut doc = Document::with_version("1.7"); @@ -287,7 +283,6 @@ fn refdiff_all_four_function_types_via_separation() { /// Axial and radial shadings with `/Extend`. §8.7.4.5.3 and §8.7.4.5.4 are dense /// and the extend/`t` mapping is easy to read two ways. #[test]-#[ignore] fn refdiff_axial_and_radial_shadings() {     let mut doc = Document::with_version("1.7");     let f = doc.add_object(Stream::new(@@ -359,7 +354,6 @@ fn refdiff_axial_and_radial_shadings() { /// are both easy to invert silently — a flipped image still "looks like an /// image". #[test]-#[ignore] fn refdiff_image_placement_decode_and_stencil() {     let mut doc = Document::with_version("1.7");     // 2x2 RGB, deliberately asymmetric so a flip in either axis is visible.
pdf/src/main/rust/src/reference_diff_tests_part4.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part4.rs b/pdf/src/main/rust/src/reference_diff_tests_part4.rsindex e77cd2bf21..99b8da84bb 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part4.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part4.rs@@ -1,6 +1,5 @@ /// A `/Decode` array that inverts a grayscale image (§8.9.5.2, Table 89). #[test]-#[ignore] fn refdiff_image_decode_array_inversion() {     let mut doc = Document::with_version("1.7");     let gray = vec![0u8, 64, 128, 255];@@ -42,7 +41,6 @@ fn refdiff_image_decode_array_inversion() { /// canonical self-consistent mistake here: the content still appears, just in /// the wrong place or unclipped. #[test]-#[ignore] fn refdiff_form_xobject_matrix_and_bbox_clip() {     let mut doc = Document::with_version("1.7");     let inner = Content {@@ -85,7 +83,6 @@ fn refdiff_form_xobject_matrix_and_bbox_clip() { /// Nested clipping with both winding rules, and the `W n` deferral rule /// (§8.5.4: the clip takes effect only after the path-painting operator). #[test]-#[ignore] fn refdiff_nested_and_evenodd_clipping() {     let ops = vec![         op("q", vec![]),@@ -124,7 +121,6 @@ fn refdiff_nested_and_evenodd_clipping() { /// on the glyph's first painting operator. The square glyph in this fixture /// disappeared entirely; the triangle glyph was drawn from the wrong start point. #[test]-#[ignore] fn refdiff_type3_font_text_positioning() {     let mut doc = Document::with_version("1.7");     // Glyph "a": a filled square in the left 700/1000 of the em.@@ -215,7 +211,6 @@ fn refdiff_type3_font_text_positioning() { /// Constant alpha (`/ca`) with overlapping fills — §11.6.4.4. The compositing /// arithmetic is a place where "close enough" hides a systematic error. #[test]-#[ignore] fn refdiff_constant_alpha_compositing() {     let mut doc = Document::with_version("1.7");     let gs = doc.add_object(dictionary! { "Type" => "ExtGState", "ca" => Object::Real(0.5) });@@ -252,7 +247,6 @@ fn refdiff_constant_alpha_compositing() { /// `/Rotate` and a `/CropBox` offset from the `/MediaBox` origin (§7.7.3.3, /// §14.11.2). Both renderers must independently agree on where the ink lands. #[test]-#[ignore] fn refdiff_rotate_and_cropbox() {     for rotate in [0i64, 90, 180, 270] {         let ops = vec![@@ -278,7 +272,6 @@ fn refdiff_rotate_and_cropbox() { /// Dash patterns (§8.4.3.6): phase handling and the odd-length-array rule are /// both easy to read two ways. #[test]-#[ignore] fn refdiff_dash_patterns() {     let ops = vec![         op("w", vec![n(6.0)]),@@ -309,7 +302,6 @@ fn refdiff_dash_patterns() {  /// Luminosity soft mask (§11.6.5.2) driven by an axial shading. #[test]-#[ignore] fn refdiff_luminosity_soft_mask() {     let mut doc = Document::with_version("1.7");     let f = doc.add_object(Stream::new(
pdf/src/main/rust/src/reference_diff_tests_part5.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part5.rs b/pdf/src/main/rust/src/reference_diff_tests_part5.rsindex a0d1777d59..c5b893c749 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part5.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part5.rs@@ -96,7 +96,6 @@ /// leaked digit, which is why the `None` arm of `ops.get_mut(i + 1)` still /// renames. #[test]-#[ignore] fn refdiff_root_cause_d0_mangles_the_next_operator() {     let cases: [(&str, &str, usize); 2] = [         ("700 0 d0\n50 0 600 600 re\nf", "re", 4),@@ -168,7 +167,6 @@ fn spec_lab_to_srgb(l: f64, a: f64, b: f64, wp: [f64; 3]) -> [f64; 3] { /// which is defensible as a colour-management policy but is not the XYZ that /// §8.6.5.4 defines. NO PATCH PROPOSED. #[test]-#[ignore] fn refdiff_lab_and_calrgb_colour() {     const WP: [f64; 3] = [0.9505, 1.0, 1.089];     let lab = Object::Array(vec![@@ -260,7 +258,6 @@ fn refdiff_lab_and_calrgb_colour() { /// the shading's target space, and applying it in the wrong direction still /// produces a plausible-looking gradient. #[test]-#[ignore] fn refdiff_function_based_shading_matrix_and_domain() {     let mut doc = Document::with_version("1.7");     let f = doc.add_object(Stream::new(@@ -302,7 +299,6 @@ fn refdiff_function_based_shading_matrix_and_domain() { /// page with `/Decode [0 1]`, and `/Decode [1 0]` reverses that. Inverting a /// stencil is invisible to any test that only asserts "some ink appeared". #[test]-#[ignore] fn refdiff_image_mask_decode_polarity() {     let mut doc = Document::with_version("1.7");     let stencil: Vec<u8> = (0..8).map(|_| 0xF0u8).collect();@@ -360,7 +356,6 @@ fn refdiff_image_mask_decode_polarity() { /// bitmap plus a lattice (`Prim::ImageTiled`), which is a representation choice /// nothing outside this crate has ever checked. #[test]-#[ignore] fn refdiff_tiling_pattern_step_and_matrix() {     let mut doc = Document::with_version("1.7");     let cell = Content {
pdf/src/main/rust/src/reference_diff_tests_part6.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part6.rs b/pdf/src/main/rust/src/reference_diff_tests_part6.rsindex 05d6d3622b..7473a737de 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part6.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part6.rs@@ -14,7 +14,6 @@ /// would show nothing at all in that region, which is a 100%-vs-0% difference, /// far outside any tolerance in this file. #[test]-#[ignore] fn refdiff_luminosity_soft_mask_backdrop_colour() {     let build = |bc: Option<[f64; 3]>| {         let mut doc = Document::with_version("1.7");@@ -113,7 +112,6 @@ fn refdiff_luminosity_soft_mask_backdrop_colour() { /// roughly 140 device px across — because chord error scales with radius and a /// small curve would pass whatever the step count. #[test]-#[ignore] fn refdiff_bezier_flattening_at_scale() {     // Four cubics approximating a circle, the classic 0.5523 magic number.     let (cx, cy, r) = (100.0f64, 100.0f64, 70.0);@@ -190,7 +188,6 @@ fn refdiff_bezier_flattening_at_scale() { /// by the Kotlin consumer, which is a cross-boundary loss this harness cannot /// see either, because it measures the prim stream and the loss happens after. #[test]-#[ignore] fn refdiff_harness_refuses_a_page_it_cannot_draw() {     // Minimal 8x8 greyscale baseline JPEG.     let jpeg: Vec<u8> = {@@ -304,7 +301,6 @@ fn refdiff_harness_refuses_a_page_it_cannot_draw() { /// zoom. The same circle painted as a fill carries ~0.42 device px of chord /// error at this scale — small, but it is the thing that does not scale away. #[test]-#[ignore] fn refdiff_curved_clip_is_zoom_correct() {     let (cx, cy, r) = (100.0f64, 100.0f64, 70.0);     let k = 0.552_284_749_8 * r;
pdf/src/main/rust/src/reference_diff_tests_part7.rs
diff --git a/pdf/src/main/rust/src/reference_diff_tests_part7.rs b/pdf/src/main/rust/src/reference_diff_tests_part7.rsindex 621fc0dc50..5267ea192b 100644--- a/pdf/src/main/rust/src/reference_diff_tests_part7.rs+++ b/pdf/src/main/rust/src/reference_diff_tests_part7.rs@@ -74,7 +74,6 @@ /// Not applied here: `interpret.rs` belongs to `fix-interp`. This test RECORDS /// the numbers and bounds them loosely so a change in either direction shows up. #[test]-#[ignore] fn refdiff_flatness_operator_amplifies_faceting() {     let (cx, cy, r) = (100.0f64, 100.0f64, 70.0);     let k = 0.552_284_749_8 * r;