From 116f5cbbaade46d152a9bad5bdadb60c674af9f8 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:06:05 +0100 Subject: [PATCH 1/9] test(ui): wait for the installed fonts before the Format text font field is opened (#9053) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Format text font field is shut ("Loading fonts…") until the installed-font catalogue has finished its first scan, and a list opened earlier closes when the catalogue arrives. Two tests opened it after a fixed number of frames, so a slow or contended runner (the Windows gate runs the whole `it` binary in one process) clicked a shut field. They now wait for App::installed_fonts_pending to clear first. --- crates/ui-egui/src/app.rs | 15 +++++++++++++++ crates/ui-egui/tests/it/edit.rs | 4 ++++ crates/ui-egui/tests/it/editing.rs | 3 +++ 3 files changed, 22 insertions(+) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 97e0124dd6..b4c07d5b03 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -676,6 +676,21 @@ impl PdfCraftApp { self.views.iter().any(|v| v.render_pending()) } + /// `true` until the installed fonts have been found and catalogued, which the Format text + /// font field starts when it first shows. The field is shut ("Loading fonts…") while the + /// catalogue is built, and a list opened before that closes when it arrives, so a headless + /// test waits for this to be `false` before it opens the field. + pub fn installed_fonts_pending(&self) -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + self.document_fonts.as_ref().is_none_or(|fonts| !fonts.catalog.is_ready()) + } + #[cfg(target_arch = "wasm32")] + { + false + } + } + /// Check whether a tool group is pinned to Home. pub fn is_tool_pinned(&self, id: &str) -> bool { self.pinned_tools.iter().any(|t| t == id) diff --git a/crates/ui-egui/tests/it/edit.rs b/crates/ui-egui/tests/it/edit.rs index e6b9dd910b..e7ae037ec3 100644 --- a/crates/ui-egui/tests/it/edit.rs +++ b/crates/ui-egui/tests/it/edit.rs @@ -191,6 +191,10 @@ fn format_text_font_picker_applies_document_font_to_added_text() { assert!(h.execute("edit.edit_text")); h.state_mut().views[0].session.content.selected = Some((0, 0)); h.run_steps(4); + // The font field is shut ("Loading fonts…") while the installed fonts are catalogued on a + // worker thread, and a list opened before then closes when the catalogue arrives. A runner + // that reads many fonts (Windows) is still at it after these frames. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); font_node.click(); diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index aa290c7678..fab1699e6d 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -10578,6 +10578,9 @@ fn format_panel_shows_selection_size_and_updates_after_font_applied() { let size_node = h.get_by_role_and_label(Role::SpinButton, "Font size"); assert_eq!(size_node.value().as_deref(), Some("12"), "size text input value is 12"); + // The font field reads "Loading fonts…" and is shut while the installed fonts are catalogued + // on a worker thread; a runner that reads many fonts (Windows) is still at it after the frames above. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); assert_eq!(font_node.value().as_deref(), Some("Helvetica"), "initial font is Helvetica"); From 7627f5f7e826c870c5f991e036e64442e94c7b60 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:16:11 +0100 Subject: [PATCH 2/9] test(ui): wait for the missing-file notice instead of four frames (#9053) A Windows nextest run (trial, 9261 tests) failed opening_a_missing_file_fails_and_tells_the_user: the failed read is reported from a background load, which four frames did not always cover. --- crates/ui-egui/tests/it/editing.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index fab1699e6d..fe16d127f3 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -911,11 +911,12 @@ fn opening_the_same_path_again_focuses_its_tab() { fn opening_a_missing_file_fails_and_tells_the_user() { let mut h = session_harness(|_| {}); let missing = std::env::temp_dir().join(format!("pdfcraft-no-such-file-{}.pdf", std::process::id())); - // The open is queued; its failure is reported once the read fails. + // The open is queued; its failure is reported once the read fails, which is not a fixed number + // of frames away on a loaded runner, so wait for the notice. assert_eq!(h.state_mut().open_path(&missing.to_string_lossy()), OpenOutcome::Pending); - h.run_steps(4); + let reported = support::step_until(&mut h, |h| support::shown_notice(h).is_some()); + assert!(reported, "the failure is still reported to the user"); assert!(h.state().views.is_empty()); - assert!(support::shown_notice(&h).is_some(), "the failure is still reported to the user"); } #[test] From 1d25e0a525a28041794b763f92e2eed016af55fa Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:06:05 +0100 Subject: [PATCH 3/9] test(ui): wait for the installed fonts before the Format text font field is opened (#9053) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Format text font field is shut ("Loading fonts…") until the installed-font catalogue has finished its first scan, and a list opened earlier closes when the catalogue arrives. Two tests opened it after a fixed number of frames, so a slow or contended runner (the Windows gate runs the whole `it` binary in one process) clicked a shut field. They now wait for App::installed_fonts_pending to clear first. (cherry picked from commit 116f5cbbaade46d152a9bad5bdadb60c674af9f8) --- crates/ui-egui/src/app.rs | 15 +++++++++++++++ crates/ui-egui/tests/it/edit.rs | 4 ++++ crates/ui-egui/tests/it/editing.rs | 3 +++ 3 files changed, 22 insertions(+) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 97e0124dd6..b4c07d5b03 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -676,6 +676,21 @@ impl PdfCraftApp { self.views.iter().any(|v| v.render_pending()) } + /// `true` until the installed fonts have been found and catalogued, which the Format text + /// font field starts when it first shows. The field is shut ("Loading fonts…") while the + /// catalogue is built, and a list opened before that closes when it arrives, so a headless + /// test waits for this to be `false` before it opens the field. + pub fn installed_fonts_pending(&self) -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + self.document_fonts.as_ref().is_none_or(|fonts| !fonts.catalog.is_ready()) + } + #[cfg(target_arch = "wasm32")] + { + false + } + } + /// Check whether a tool group is pinned to Home. pub fn is_tool_pinned(&self, id: &str) -> bool { self.pinned_tools.iter().any(|t| t == id) diff --git a/crates/ui-egui/tests/it/edit.rs b/crates/ui-egui/tests/it/edit.rs index e6b9dd910b..e7ae037ec3 100644 --- a/crates/ui-egui/tests/it/edit.rs +++ b/crates/ui-egui/tests/it/edit.rs @@ -191,6 +191,10 @@ fn format_text_font_picker_applies_document_font_to_added_text() { assert!(h.execute("edit.edit_text")); h.state_mut().views[0].session.content.selected = Some((0, 0)); h.run_steps(4); + // The font field is shut ("Loading fonts…") while the installed fonts are catalogued on a + // worker thread, and a list opened before then closes when the catalogue arrives. A runner + // that reads many fonts (Windows) is still at it after these frames. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); font_node.click(); diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index aa290c7678..fab1699e6d 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -10578,6 +10578,9 @@ fn format_panel_shows_selection_size_and_updates_after_font_applied() { let size_node = h.get_by_role_and_label(Role::SpinButton, "Font size"); assert_eq!(size_node.value().as_deref(), Some("12"), "size text input value is 12"); + // The font field reads "Loading fonts…" and is shut while the installed fonts are catalogued + // on a worker thread; a runner that reads many fonts (Windows) is still at it after the frames above. + crate::support::wait_until(&mut h, "the installed fonts", |app| !app.installed_fonts_pending()); let font_node = h.get_by_role_and_label(Role::ComboBox, "Font family"); assert_eq!(font_node.value().as_deref(), Some("Helvetica"), "initial font is Helvetica"); From 2b672e5f7dd049e9262598800fb327096ad466de Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:16:11 +0100 Subject: [PATCH 4/9] test(ui): wait for the missing-file notice instead of four frames (#9053) A Windows nextest run (trial, 9261 tests) failed opening_a_missing_file_fails_and_tells_the_user: the failed read is reported from a background load, which four frames did not always cover. (cherry picked from commit 7627f5f7e826c870c5f991e036e64442e94c7b60) --- crates/ui-egui/tests/it/editing.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index fab1699e6d..fe16d127f3 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -911,11 +911,12 @@ fn opening_the_same_path_again_focuses_its_tab() { fn opening_a_missing_file_fails_and_tells_the_user() { let mut h = session_harness(|_| {}); let missing = std::env::temp_dir().join(format!("pdfcraft-no-such-file-{}.pdf", std::process::id())); - // The open is queued; its failure is reported once the read fails. + // The open is queued; its failure is reported once the read fails, which is not a fixed number + // of frames away on a loaded runner, so wait for the notice. assert_eq!(h.state_mut().open_path(&missing.to_string_lossy()), OpenOutcome::Pending); - h.run_steps(4); + let reported = support::step_until(&mut h, |h| support::shown_notice(h).is_some()); + assert!(reported, "the failure is still reported to the user"); assert!(h.state().views.is_empty()); - assert!(support::shown_notice(&h).is_some(), "the failure is still reported to the user"); } #[test] From 910760ffd638211ea1cc057a1dba5346a069b5cd Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:52:19 +0100 Subject: [PATCH 5/9] ci: Windows tests only what is Windows-specific, through nextest and rust-lld (#9062) Windows runs the crates with cfg(windows) code or tests, as Ubuntu does, with nextest. The 23 crates without any, xtask, pdfcraft-web and the OCR worker stay on Ubuntu (cargo xtask ci runs them). The Windows link step uses rust-lld. The warm leg builds exactly what the gate runs. --- .github/workflows/ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8ac8fe7e0..78b0d4fa36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,14 +76,23 @@ jobs: PDFCRAFT_REQUIRE_WINRES=1 CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0 + CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=rust-lld.exe # A cold run (a lockfile or toolchain change, or an evicted cache) took 89 of 90 minutes # (run 46809231999), so 120 leaves room for it and for the cache save. Windows checks what # differs by platform: the build (with resources) and the tests. Clippy runs on Linux in # `cargo xtask ci`; lints don't differ by platform. timeout-minutes: 120 - command: cargo test --workspace --locked + # Windows tests what only Windows can show: the crates with Windows-specific code or tests + # (`cfg(windows)` paths, the Windows spooler, winres, the native UI), through nextest as Linux + # does. The crates left out have no `cfg(windows)` code and run the same tests on Linux in + # `cargo xtask ci`; so do pdfcraft-web (wasm) and the OCR worker. A new crate is tested here + # until it is added to the list, so the list can only be too short, not make a test vanish. + command: | + cargo nextest run --workspace --lib --bins --tests --no-fail-fast --locked --exclude pdfcraft-web --exclude pdfcraft-ocr-worker --exclude pdfcraft-a11y --exclude pdfcraft-annot --exclude pdfcraft-audit --exclude pdfcraft-compare --exclude pdfcraft-content --exclude pdfcraft-cos --exclude pdfcraft-crypt --exclude pdfcraft-edit --exclude pdfcraft-export --exclude pdfcraft-filters --exclude pdfcraft-fonts --exclude pdfcraft-forms --exclude pdfcraft-geom --exclude pdfcraft-measure --exclude pdfcraft-model --exclude pdfcraft-oracle --exclude pdfcraft-organize --exclude pdfcraft-prc-render --exclude pdfcraft-preflight --exclude pdfcraft-redact --exclude pdfcraft-testkit --exclude pdfcraft-xfa --exclude pdfcraft-xfdf --exclude xtask + cargo test --workspace --doc --locked --exclude pdfcraft-web --exclude pdfcraft-ocr-worker --exclude pdfcraft-a11y --exclude pdfcraft-annot --exclude pdfcraft-audit --exclude pdfcraft-compare --exclude pdfcraft-content --exclude pdfcraft-cos --exclude pdfcraft-crypt --exclude pdfcraft-edit --exclude pdfcraft-export --exclude pdfcraft-filters --exclude pdfcraft-fonts --exclude pdfcraft-forms --exclude pdfcraft-geom --exclude pdfcraft-measure --exclude pdfcraft-model --exclude pdfcraft-oracle --exclude pdfcraft-organize --exclude pdfcraft-prc-render --exclude pdfcraft-preflight --exclude pdfcraft-redact --exclude pdfcraft-testkit --exclude pdfcraft-xfa --exclude pdfcraft-xfdf --exclude xtask # On main and manual runs a `cache warm (windows-latest)` leg builds the tests (the build # `command` does, without running them) and saves the dependency cache as soon as that # succeeds. Without it the cache is saved only at the end of a green gate, and a main whose # Windows tests fail never saves it, so every full-ci pull request compiled cold (#9054). - warm-command: cargo test --workspace --no-run --locked + # The same build as `command`, flag for flag, so the warm leg saves what the gate restores. + warm-command: cargo nextest run --workspace --lib --bins --tests --no-run --locked --exclude pdfcraft-web --exclude pdfcraft-ocr-worker --exclude pdfcraft-a11y --exclude pdfcraft-annot --exclude pdfcraft-audit --exclude pdfcraft-compare --exclude pdfcraft-content --exclude pdfcraft-cos --exclude pdfcraft-crypt --exclude pdfcraft-edit --exclude pdfcraft-export --exclude pdfcraft-filters --exclude pdfcraft-fonts --exclude pdfcraft-forms --exclude pdfcraft-geom --exclude pdfcraft-measure --exclude pdfcraft-model --exclude pdfcraft-oracle --exclude pdfcraft-organize --exclude pdfcraft-prc-render --exclude pdfcraft-preflight --exclude pdfcraft-redact --exclude pdfcraft-testkit --exclude pdfcraft-xfa --exclude pdfcraft-xfdf --exclude xtask From f5becd53f23423e5ba6e5a335585b6018863b538 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:59:20 +0100 Subject: [PATCH 6/9] test(ui): settle the Pages sidebar before the shadow comparison renders it (#9053) A Windows nextest run failed rendered_page_content_is_identical_with_and_without_decoration at a sidebar pixel: (119,119,124) with shadows on, (204,230,255), the page artwork's colour, with them off. The sidebar thumbnails arrived between the two renders, and render_pending does not cover them. --- crates/ui-egui/tests/page_shadows.rs | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/ui-egui/tests/page_shadows.rs b/crates/ui-egui/tests/page_shadows.rs index 0e419d2631..20fc65bb54 100644 --- a/crates/ui-egui/tests/page_shadows.rs +++ b/crates/ui-egui/tests/page_shadows.rs @@ -112,6 +112,7 @@ fn rendered_page_content_is_identical_with_and_without_decoration() { std::thread::sleep(std::time::Duration::from_millis(5)); } assert!(!h.state().render_pending(), "the actual PDF raster must be ready"); + settle_sidebar(&mut h); let rects = h.state().views[0].visible_page_rects().to_vec(); let enabled = h.render().unwrap(); h.set_option("show_page_edge_shadows", "false").unwrap(); @@ -145,6 +146,35 @@ fn rendered_page_content_is_identical_with_and_without_decoration() { } } +/// Step until the pixels outside the viewport (the Pages sidebar) have not changed for a while. The +/// sidebar fills its thumbnails in on its own schedule and `render_pending` does not cover them: a +/// thumbnail that arrived between the two renders made them differ outside the pages. +fn settle_sidebar(h: &mut Harness<'static, PdfCraftApp>) { + let outside = |h: &mut Harness<'static, PdfCraftApp>| { + let viewport = h.state().views[0].viewport_rect(); + let image = h.render().unwrap(); + let (left, right) = (viewport.left().floor() as u32, viewport.right().ceil() as u32); + let mut pixels = Vec::new(); + for y in 0..image.height() { + pixels.extend((0..left).chain(right..image.width()).map(|x| *image.get_pixel(x, y))); + } + pixels + }; + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(30); + let mut last = outside(h); + let mut unchanged_since = std::time::Instant::now(); + while unchanged_since.elapsed() < std::time::Duration::from_millis(300) { + assert!(std::time::Instant::now() < deadline, "the Pages sidebar never stopped changing"); + h.run_steps(2); + std::thread::sleep(std::time::Duration::from_millis(10)); + let now = outside(h); + if now != last { + last = now; + unchanged_since = std::time::Instant::now(); + } + } +} + fn harness(theme: &str) -> Harness<'static, PdfCraftApp> { let theme = theme.to_string(); let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |cc| { From 47a03cd44680f5ea9d8d443bc3506c9278279868 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:59:20 +0100 Subject: [PATCH 7/9] test(ui): settle the Pages sidebar before the shadow comparison renders it (#9053) A Windows nextest run failed rendered_page_content_is_identical_with_and_without_decoration at a sidebar pixel: (119,119,124) with shadows on, (204,230,255), the page artwork's colour, with them off. The sidebar thumbnails arrived between the two renders, and render_pending does not cover them. (cherry picked from commit f5becd53f23423e5ba6e5a335585b6018863b538) --- crates/ui-egui/tests/page_shadows.rs | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/ui-egui/tests/page_shadows.rs b/crates/ui-egui/tests/page_shadows.rs index 0e419d2631..20fc65bb54 100644 --- a/crates/ui-egui/tests/page_shadows.rs +++ b/crates/ui-egui/tests/page_shadows.rs @@ -112,6 +112,7 @@ fn rendered_page_content_is_identical_with_and_without_decoration() { std::thread::sleep(std::time::Duration::from_millis(5)); } assert!(!h.state().render_pending(), "the actual PDF raster must be ready"); + settle_sidebar(&mut h); let rects = h.state().views[0].visible_page_rects().to_vec(); let enabled = h.render().unwrap(); h.set_option("show_page_edge_shadows", "false").unwrap(); @@ -145,6 +146,35 @@ fn rendered_page_content_is_identical_with_and_without_decoration() { } } +/// Step until the pixels outside the viewport (the Pages sidebar) have not changed for a while. The +/// sidebar fills its thumbnails in on its own schedule and `render_pending` does not cover them: a +/// thumbnail that arrived between the two renders made them differ outside the pages. +fn settle_sidebar(h: &mut Harness<'static, PdfCraftApp>) { + let outside = |h: &mut Harness<'static, PdfCraftApp>| { + let viewport = h.state().views[0].viewport_rect(); + let image = h.render().unwrap(); + let (left, right) = (viewport.left().floor() as u32, viewport.right().ceil() as u32); + let mut pixels = Vec::new(); + for y in 0..image.height() { + pixels.extend((0..left).chain(right..image.width()).map(|x| *image.get_pixel(x, y))); + } + pixels + }; + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(30); + let mut last = outside(h); + let mut unchanged_since = std::time::Instant::now(); + while unchanged_since.elapsed() < std::time::Duration::from_millis(300) { + assert!(std::time::Instant::now() < deadline, "the Pages sidebar never stopped changing"); + h.run_steps(2); + std::thread::sleep(std::time::Duration::from_millis(10)); + let now = outside(h); + if now != last { + last = now; + unchanged_since = std::time::Instant::now(); + } + } +} + fn harness(theme: &str) -> Harness<'static, PdfCraftApp> { let theme = theme.to_string(); let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |cc| { From 5a9749b25708eafc8c033c633ac296d1838c6682 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:47:51 +0700 Subject: [PATCH 8/9] ci: drop rust-lld from the Windows gate (#9062) A same-machine comparison did not finish within its time limit, and the cold runs show no gain (80.5 minutes of build with it against 83.9 without), so it is not kept. --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78b0d4fa36..bb6732a503 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,6 @@ jobs: PDFCRAFT_REQUIRE_WINRES=1 CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0 - CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=rust-lld.exe # A cold run (a lockfile or toolchain change, or an evicted cache) took 89 of 90 minutes # (run 46809231999), so 120 leaves room for it and for the cache save. Windows checks what # differs by platform: the build (with resources) and the tests. Clippy runs on Linux in From eece0eb397cfa12120855aeb38e629222bf8832d Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Thu, 3 Dec 2026 01:31:45 +0700 Subject: [PATCH 9/9] ci: retrigger the gate after the Actions outage dropped the last push (#9062)