From 5e7675c043dbc59c44e65ff51e43bf00b64a89dd Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Wed, 11 Mar 2026 12:00:44 +0100 Subject: [PATCH] test(pack): add list_installed_roots tests; run pack tests single-threaded Two new tests mirror the weft-runtime package_store_roots tests: - list_installed_roots_uses_weft_app_store_when_set - list_installed_roots_includes_system_path wsl-test.sh: add --test-threads=1 for weft-pack to prevent WEFT_APP_STORE env var races between install, uninstall, and the new list_roots tests. --- crates/weft-pack/src/main.rs | 31 +++++++++++++++++++++++++++++++ scripts/wsl-test.sh | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/weft-pack/src/main.rs b/crates/weft-pack/src/main.rs index c8a17ed..12461e3 100644 --- a/crates/weft-pack/src/main.rs +++ b/crates/weft-pack/src/main.rs @@ -477,4 +477,35 @@ entry = "ui/index.html" assert!(result.is_err()); let _ = fs::remove_dir_all(&tmp); } + + #[test] + fn list_installed_roots_uses_weft_app_store_when_set() { + let prior = std::env::var("WEFT_APP_STORE").ok(); + unsafe { std::env::set_var("WEFT_APP_STORE", "/custom/store") }; + let roots = list_installed_roots(); + unsafe { + match prior { + Some(v) => std::env::set_var("WEFT_APP_STORE", v), + None => std::env::remove_var("WEFT_APP_STORE"), + } + } + assert_eq!(roots, vec![PathBuf::from("/custom/store")]); + } + + #[test] + fn list_installed_roots_includes_system_path() { + let prior = std::env::var("WEFT_APP_STORE").ok(); + unsafe { std::env::remove_var("WEFT_APP_STORE") }; + let roots = list_installed_roots(); + unsafe { + if let Some(v) = prior { + std::env::set_var("WEFT_APP_STORE", v); + } + } + assert!( + roots + .iter() + .any(|p| p == &PathBuf::from("/usr/share/weft/apps")) + ); + } } diff --git a/scripts/wsl-test.sh b/scripts/wsl-test.sh index 6481129..e57a245 100644 --- a/scripts/wsl-test.sh +++ b/scripts/wsl-test.sh @@ -36,7 +36,7 @@ cargo test -p weft-runtime -- --test-threads=1 2>&1 echo "" echo "==> cargo test -p weft-pack" -cargo test -p weft-pack 2>&1 +cargo test -p weft-pack -- --test-threads=1 2>&1 echo "" echo "ALL DONE"