From 0ae4e9c10d9da5a9f3c4bb90740554012e3452c1 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 19 Nov 2026 05:14:13 +0700 Subject: [PATCH] tests: the shortcut sheet test compares two exports without the clock's stamps The PDF writer dates each file and makes its IDs from the clock, so two sheet exports on either side of a second boundary differed there and the test failed on main's coverage run. --- crates/ui-egui/src/shortcut_editor.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 1d2a5fb81c..bb71115d8a 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -3781,7 +3781,22 @@ mod tests { let (csv_off, csv_on) = (String::from_utf8_lossy(csv_off), String::from_utf8_lossy(csv_on)); assert!(!csv_off.contains(&hold), "off, the CSV file lists no hold"); assert!(csv_on.contains(&swap[0].shortcut), "on, the CSV file lists it: {}", swap[0].shortcut); - assert_eq!(sheet_off, sheet_off_again, "the sheet is the same each time"); + // The writer stamps each file with the clock: its dates and its ID (fixed width), which differ + // between two exports a second apart. The rest of the file is the same each time. + let unstamped = |pdf: &[u8]| { + let mut b: Vec = pdf.iter().map(|&c| if c.is_ascii_digit() { b'0' } else { c }).collect(); + for key in [&b"InstanceID>"[..], b"DocumentID>", b"/ID["] { + let mut at = 0; + while let Some(i) = b[at..].windows(key.len()).position(|w| w == key) { + let start = at + i + key.len(); + let end = b[start..].iter().position(|&c| c == b'<' || c == b']').map_or(b.len(), |e| start + e); + b[start..end].fill(b'?'); + at = end; + } + } + b + }; + assert_eq!(unstamped(sheet_off), unstamped(sheet_off_again), "the sheet is the same each time"); assert_ne!(sheet_off, sheet_on, "on, the sheet lists the hold"); }