From 0cb03234f692c351c1bd7ee52c69da5740dde16c Mon Sep 17 00:00:00 2001 From: Christian Lappin Date: Sat, 14 Nov 2026 14:53:31 -0500 Subject: [PATCH] Keep the download update test stable in Linux coverage --- Cargo.lock | 1 + crates/ui-egui/Cargo.toml | 3 +++ crates/ui-egui/tests/it/updates.rs | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2ad337ab20..b7596fa0f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5014,6 +5014,7 @@ dependencies = [ "serde_json", "skrifa 0.44.0", "sys-locale", + "tempfile", "toml", "unicode-bidi", "wasm-bindgen", diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 93d3a4c9ad..cca968360b 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -113,3 +113,6 @@ toml = "1" [target.'cfg(target_os = "macos")'.dev-dependencies] # Only synthetic attribute fixtures use xattr; product reads/writes use rustix. xattr = "1.6" + +[target.'cfg(target_os = "linux")'.dev-dependencies] +tempfile = "3.27" diff --git a/crates/ui-egui/tests/it/updates.rs b/crates/ui-egui/tests/it/updates.rs index 61a0e03ee5..f6c6c03bd0 100644 --- a/crates/ui-egui/tests/it/updates.rs +++ b/crates/ui-egui/tests/it/updates.rs @@ -49,6 +49,31 @@ fn settle(h: &mut Harness<'static, PdfCraftApp>) { #[test] fn a_newer_release_is_offered_for_download() { + #[cfg(target_os = "linux")] + { + const FIXTURE: &str = "PDFCRAFT_TEST_UPDATE_DOWNLOAD_FIXTURE"; + if craft_update::self_update::is_self_updating(&pdfcraft_ui_egui::UPDATE_APP) { + assert!(std::env::var_os(FIXTURE).is_none(), "the fixture must be detected as a Cargo build"); + // nextest's extracted archive can omit Cargo's metadata. Give the child a + // private build directory with the marker the updater uses to identify it. + let current = std::env::current_exe().unwrap(); + let build = tempfile::tempdir_in(current.parent().unwrap()).unwrap(); + std::fs::write(build.path().join(".rustc_info.json"), "{}").unwrap(); + let exe = build.path().join("update-download-test"); + if std::fs::hard_link(¤t, &exe).is_err() { + std::fs::copy(¤t, &exe).unwrap(); + } + let output = std::process::Command::new(exe) + .args(["--exact", "updates::a_newer_release_is_offered_for_download", "--nocapture"]) + .env(FIXTURE, "1") + .env_remove(craft_update::self_update::DEV_VAR) + .output() + .unwrap(); + assert!(output.status.success(), "{}\n{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr)); + assert!(String::from_utf8_lossy(&output.stdout).contains("1 passed")); + return; + } + } let mut h = harness(Ok(Some("v99.0.0"))); h.state_mut().execute("help.check_updates"); settle(&mut h);