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.
This commit is contained in:
Marco Allegretti 2026-03-11 12:00:44 +01:00
parent cab3a4a956
commit 5e7675c043
2 changed files with 32 additions and 1 deletions

View file

@ -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"))
);
}
}

View file

@ -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"