test(appd): add appd_socket_path tests; run appd tests single-threaded

Two new tests cover appd_socket_path():
- appd_socket_path_uses_override_env: WEFT_APPD_SOCKET takes precedence
- appd_socket_path_errors_without_xdg_and_no_override: returns error when
  both WEFT_APPD_SOCKET and XDG_RUNTIME_DIR are unset

wsl-test.sh: add --test-threads=1 for weft-appd to prevent WEFT_RUNTIME_BIN
races between the supervisor integration tests.
This commit is contained in:
Marco Allegretti 2026-03-11 12:40:05 +01:00
parent 71597580ba
commit bded9455f5
2 changed files with 37 additions and 1 deletions

View file

@ -343,6 +343,42 @@ mod tests {
Arc::new(Mutex::new(SessionRegistry::default())) Arc::new(Mutex::new(SessionRegistry::default()))
} }
#[test]
fn appd_socket_path_uses_override_env() {
let prior = std::env::var("WEFT_APPD_SOCKET").ok();
unsafe { std::env::set_var("WEFT_APPD_SOCKET", "/tmp/custom.sock") };
let path = appd_socket_path().unwrap();
unsafe {
match prior {
Some(v) => std::env::set_var("WEFT_APPD_SOCKET", v),
None => std::env::remove_var("WEFT_APPD_SOCKET"),
}
}
assert_eq!(path, PathBuf::from("/tmp/custom.sock"));
}
#[test]
fn appd_socket_path_errors_without_xdg_and_no_override() {
let prior_sock = std::env::var("WEFT_APPD_SOCKET").ok();
let prior_xdg = std::env::var("XDG_RUNTIME_DIR").ok();
unsafe {
std::env::remove_var("WEFT_APPD_SOCKET");
std::env::remove_var("XDG_RUNTIME_DIR");
}
let result = appd_socket_path();
unsafe {
match prior_sock {
Some(v) => std::env::set_var("WEFT_APPD_SOCKET", v),
None => {}
}
match prior_xdg {
Some(v) => std::env::set_var("XDG_RUNTIME_DIR", v),
None => {}
}
}
assert!(result.is_err());
}
#[tokio::test] #[tokio::test]
async fn dispatch_launch_returns_ack() { async fn dispatch_launch_returns_ack() {
let reg = make_registry(); let reg = make_registry();

View file

@ -28,7 +28,7 @@ cargo test -p weft-compositor 2>&1
echo "" echo ""
echo "==> cargo test -p weft-appd" echo "==> cargo test -p weft-appd"
cargo test -p weft-appd 2>&1 cargo test -p weft-appd -- --test-threads=1 2>&1
echo "" echo ""
echo "==> cargo test -p weft-runtime" echo "==> cargo test -p weft-runtime"