Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -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");
}
2 changes: 1 addition & 1 deletion src-tauri/src/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/space/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions src-tauri/src/space/local/extensions/updates/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct Shop {
/// (path and query, user agent)
asked: Mutex<Vec<(String, String)>>,
silent: AtomicBool,
disconnect: AtomicBool,
/// Packages that never come.
hang: AtomicBool,
}
Expand Down Expand Up @@ -45,6 +46,9 @@ async fn open_shop() -> (Arc<Shop>, 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;
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down