From 14663173016e839109b696d22b1aa0659d52ab00 Mon Sep 17 00:00:00 2001 From: Louise Fox <2503492+KaboomFox@users.noreply.github.com> Date: Mon, 26 Oct 2026 00:04:52 +0000 Subject: [PATCH] PDF tests: exports compared byte for byte are dated alike dithered_perceptual_gradients_export_as_images_with_noise_on_the_fill compares two exports byte for byte: a stroke's file with dither and without. The export dates a file by the clock, in whole seconds (metadata::output_time, unless SOURCE_DATE_EPOCH is set), and the tests' `uncompressed` helper gave no date of its own. So the test failed whenever a second ticked between the two exports: the files then differed in /CreationDate, /ModDate, the XMP dates and the IDs made from them, and in nothing else. CI hit it on #3807. With the wall clock moved a second on each read (an LD_PRELOAD shim on clock_gettime), the test failed 5 runs of 5, and it was the only one of vectorcraft-pdf's 380 tests that did. With the helper's date fixed it passes, as do the other 379. The helper now dates its exports `created: Some(0)`, as the crate's other tests that compare whole files do (tests_editing, tests_pdf13, tests_webview). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HhvnnnD5fTFupK8WWq35un --- crates/pdf/src/tests.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/pdf/src/tests.rs b/crates/pdf/src/tests.rs index 6fa4da12a..6ebc0ceac 100644 --- a/crates/pdf/src/tests.rs +++ b/crates/pdf/src/tests.rs @@ -37,13 +37,18 @@ fn close(a: Rect, b: Rect, tol: f64) -> bool { (a.x0 - b.x0).abs() < tol && (a.y0 - b.y0).abs() < tol && (a.x1 - b.x1).abs() < tol && (a.y1 - b.y1).abs() < tol } +/// `d` exported with the default options and imported back: the document a round trip through a PDF +/// gives. fn roundtrip(d: &Document) -> Document { let bytes = export(d, &PdfOptions::default()).expect("export"); import(&bytes).expect("import") } +/// `d` exported uncompressed, dated `created: Some(0)` rather than by the clock: two exports of one +/// document are then the same bytes, where the clock's dates, in whole seconds, differ whenever a +/// second ticks between them. fn uncompressed(d: &Document) -> String { - let bytes = export(d, &PdfOptions::uncompressed()).expect("export"); + let bytes = export(d, &PdfOptions { created: Some(0), ..PdfOptions::uncompressed() }).expect("export"); String::from_utf8_lossy(&bytes).into_owned() }