Merge pull request #7350 from christianlappin/fix/7175-update-download-test

Tests: keep the update download test stable in Linux coverage
This commit is contained in:
FredApps authored and GitHub committed 2026-11-15 01:06:17 +01:00
commit c944f106dd
3 files changed
+29

No files matched your search

Generated
+1
View File
@@ -5014,6 +5014,7 @@ dependencies = [
"serde_json",
"skrifa 0.44.0",
"sys-locale",
"tempfile",
"toml",
"unicode-bidi",
"wasm-bindgen",
+3
View File
@@ -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"
+25
View File
@@ -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(&current, &exe).is_err() {
std::fs::copy(&current, &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);