Modern Apps git

← Modern-Apps.git

pdf: point Rust contract tests at the platform SafePdf sources

Commit
920b9065b8bd111cc030038cdb912f13d29752e3
Author
Vayun Mathur <[email protected]>
When
2026-11-17 09:19 UTC (19 days ago)
Parents
9ec6fe2
The pdf lint wave moved SafePdfParser.kt and SafePdfImages.kt from the util/ package to platform/ (commit 5168ccadd), but the three Rust cross-language contract tests still read the old util/ paths, so they panicked with file-not-found before asserting anything:

- geometry::geometry_tests::the_page_bound_matches_the_kotlin_consumers_clamp
- wire::tests::the_kotlin_image_budgets_are_not_below_the_rust_ones
- wire::tests::wire_version_is_not_ahead_of_the_kotlin_parser

Update the three read paths (and the KEEP IN SYNC pointer in wire.rs) to the platform/ locations. The contract values themselves were verified unchanged on both sides before touching anything: Kotlin MAX_PAGE_DIM is 20000f against Rust MAX_PAGE_DIMENSION 20000.0, Kotlin MAX_IMAGE_PIXELS is 16777216 against Rust 16*1024*1024, Kotlin MAX_IMAGE_DIM is 20000 against Rust 20000, and the Kotlin WIRE_VERSION 11 is ahead of the Rust emitted version 10, which the inequality assertions explicitly allow. No constants were changed.

Verified: cargo test -p pdf_render --lib passes twice (597 passed, 20 ignored, 0 failed each run).

Diff

pdf/src/main/rust/src/geometry_part1.rs
diff --git a/pdf/src/main/rust/src/geometry_part1.rs b/pdf/src/main/rust/src/geometry_part1.rsindex 484d41fb94..fd2f34ed3e 100644--- a/pdf/src/main/rust/src/geometry_part1.rs+++ b/pdf/src/main/rust/src/geometry_part1.rs@@ -93,7 +93,7 @@ mod geometry_tests {     fn the_page_bound_matches_the_kotlin_consumers_clamp() {         let path = concat!(             env!("CARGO_MANIFEST_DIR"),-            "/../java/com/vayunmathur/pdf/util/SafePdfParser.kt"+            "/../java/com/vayunmathur/pdf/platform/SafePdfParser.kt"         );         let src = std::fs::read_to_string(path)             .unwrap_or_else(|e| panic!("cannot read the page box's only consumer {path}: {e}"));
pdf/src/main/rust/src/wire.rs
diff --git a/pdf/src/main/rust/src/wire.rs b/pdf/src/main/rust/src/wire.rsindex 11b2084a7f..b6278cdbc4 100644--- a/pdf/src/main/rust/src/wire.rs+++ b/pdf/src/main/rust/src/wire.rs@@ -5,7 +5,7 @@ const WIRE_MAGIC: u32 = 0x50444657; // 'PDFW' /// per-image alpha). /// /// KEEP IN SYNC WITH `SafePdfParser.WIRE_VERSION` in-/// `pdf/src/main/java/com/vayunmathur/pdf/util/SafePdfParser.kt`. That constant is the+/// `pdf/src/main/java/com/vayunmathur/pdf/platform/SafePdfParser.kt`. That constant is the /// HIGHEST version the parser understands, so it may legitimately run AHEAD of this one /// (it gates the newer fields off) but must never fall behind it: the parser does not /// reject a higher version, it forward-compat parses with those gates closed and so reads
pdf/src/main/rust/src/wire_part1.rs
diff --git a/pdf/src/main/rust/src/wire_part1.rs b/pdf/src/main/rust/src/wire_part1.rsindex aa67af9243..b2fbd69b02 100644--- a/pdf/src/main/rust/src/wire_part1.rs+++ b/pdf/src/main/rust/src/wire_part1.rs@@ -214,7 +214,7 @@ mod tests {     fn kotlin_parser_src() -> String {         let path = concat!(             env!("CARGO_MANIFEST_DIR"),-            "/../java/com/vayunmathur/pdf/util/SafePdfParser.kt"+            "/../java/com/vayunmathur/pdf/platform/SafePdfParser.kt"         );         std::fs::read_to_string(path)             .unwrap_or_else(|e| panic!("cannot read the wire format's only consumer {path}: {e}"))@@ -226,7 +226,7 @@ mod tests {     fn kotlin_images_src() -> String {         let path = concat!(             env!("CARGO_MANIFEST_DIR"),-            "/../java/com/vayunmathur/pdf/util/SafePdfImages.kt"+            "/../java/com/vayunmathur/pdf/platform/SafePdfImages.kt"         );         std::fs::read_to_string(path)             .unwrap_or_else(|e| panic!("cannot read the image-budget owner {path}: {e}"))