diff --git a/src-tauri/build.rs b/src-tauri/build.rs index d860e1e6a..74c97cd23 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -1,3 +1,18 @@ fn main() { - tauri_build::build() + let windows_msvc = std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") + && std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc"); + if !windows_msvc { + tauri_build::build(); + return; + } + + // Tauri 2.6 embeds the app manifest only in the launcher binary. + // The test harness also needs Common Controls v6 for TaskDialogIndirect. + let windows = tauri_build::WindowsAttributes::new_without_app_manifest(); + println!("cargo:rustc-link-arg=/MANIFEST:EMBED"); + println!( + "cargo:rustc-link-arg=/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'" + ); + tauri_build::try_build(tauri_build::Attributes::new().windows_attributes(windows)) + .expect("Tauri Windows build setup failed"); } diff --git a/src-tauri/src/reset.rs b/src-tauri/src/reset.rs index d7c04d6c2..d6544a77a 100644 --- a/src-tauri/src/reset.rs +++ b/src-tauri/src/reset.rs @@ -1652,7 +1652,7 @@ mod tests { /// Anything under a "Volumes/T7" folder counts as another disk. fn t7_is_another_disk(a: &Path, b: &Path) -> bool { - let on_t7 = |p: &Path| p.to_string_lossy().contains("/Volumes/T7"); + let on_t7 = |p: &Path| p.ancestors().any(|ancestor| ancestor.ends_with("Volumes/T7")); on_t7(a) == on_t7(b) } diff --git a/src-tauri/src/space/client.rs b/src-tauri/src/space/client.rs index d2fc9e085..0e612f45b 100644 --- a/src-tauri/src/space/client.rs +++ b/src-tauri/src/space/client.rs @@ -1553,7 +1553,7 @@ mod tests { assert!(unused.is_empty(), "no longer talks HTTP, take it off the list: {unused:?}"); // Inside it, one pool and one way to open a connection: the switch to TLS. let ours = std::fs::read_to_string(src.join("space/client.rs")).unwrap(); - let ours = ours.split("#[cfg(test)]\nmod tests").next().unwrap(); + let (ours, _) = ours.split_once("\nmod tests {").expect("the client test module"); let builders = code(ours).filter(|(_, l)| l.contains("Client::builder(")).count(); assert_eq!(builders, 1, "one place makes team connections: link()"); let opens = code(ours).filter(|(_, l)| l.contains("TcpStream::connect")).count(); diff --git a/src-tauri/src/space/local/extensions/updates/tests.rs b/src-tauri/src/space/local/extensions/updates/tests.rs index cc0b26651..5967d0520 100644 --- a/src-tauri/src/space/local/extensions/updates/tests.rs +++ b/src-tauri/src/space/local/extensions/updates/tests.rs @@ -18,6 +18,7 @@ struct Shop { /// (path and query, user agent) asked: Mutex>, silent: AtomicBool, + disconnect: AtomicBool, /// Packages that never come. hang: AtomicBool, } @@ -45,6 +46,9 @@ async fn open_shop() -> (Arc, String) { .find_map(|l| l.to_ascii_lowercase().starts_with("user-agent:").then(|| l[11..].trim().to_string())) .unwrap_or_default(); s.asked.lock().unwrap().push((target.clone(), ua)); + if s.disconnect.load(Ordering::SeqCst) { + return; + } let hang = s.hang.load(Ordering::SeqCst) && target.starts_with("/crx/"); if s.silent.load(Ordering::SeqCst) || hang { tokio::time::sleep(Duration::from_secs(30)).await; @@ -328,7 +332,7 @@ async fn a_package_unlike_what_the_store_said_is_refused() { /// A check that gets no answer keeps what the last one found. #[tokio::test] -async fn a_silent_store_times_out_and_an_offline_one_changes_nothing() { +async fn a_silent_store_times_out_and_a_disconnect_changes_nothing() { let mut r = Rig::new().await; let id = r.add(&[("manifest.json", &m("1.0"))], Some(How::Link)); r.offer("1.1", &[("manifest.json", &m("1.1"))], ALLOWED); @@ -338,6 +342,7 @@ async fn a_silent_store_times_out_and_an_offline_one_changes_nothing() { let checked = load(&r.env.book).last_check_at; r.shop.silent.store(true, Ordering::SeqCst); + let check_timeout = r.env.check_timeout; r.env.check_timeout = Duration::from_millis(300); let t = Instant::now(); let e = check(&r.env).await.unwrap_err(); @@ -346,9 +351,10 @@ async fn a_silent_store_times_out_and_an_offline_one_changes_nothing() { assert_eq!(r.view(&id).state, State::Available); assert_eq!(r.item(&id).latest, known.latest); - // Nobody listens there. - let port = std::net::TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port(); - r.env.base = format!("http://127.0.0.1:{port}/service/update2/crx"); + // The store accepts the request and closes the connection before sending headers. + r.shop.silent.store(false, Ordering::SeqCst); + r.shop.disconnect.store(true, Ordering::SeqCst); + r.env.check_timeout = check_timeout; let e = check(&r.env).await.unwrap_err(); assert!(e.contains("could not reach"), "{e}"); let u = r.view(&id);