Skip to content

Commit 6f794ee

Browse files
committed
test(hotkey): give the Linux socket tests their own directory
Every backend::linux test failed on CI with spawn_at: Backend("Operation not permitted (os error 1)") while passing locally. bind() chmods the socket's PARENT directory to 0700, which is right in production (the parent is our own subdirectory of $XDG_RUNTIME_DIR) and impossible when the test puts its socket straight into a shared /tmp: chmodding a directory you do not own is EPERM. It passed on a laptop only because /tmp there happened to be owned by the test user. Each test now gets its own directory to own.
1 parent 65c0a04 commit 6f794ee

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎crates/hotkey/src/backend/linux.rs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,22 @@ pub fn globalshortcuts_portal_available() -> bool {
494494
mod tests {
495495
use super::*;
496496

497+
/// A socket path inside a private per-test DIRECTORY, not directly in
498+
/// the system temp dir.
499+
///
500+
/// `bind` chmods the socket's PARENT to 0700, which is correct in
501+
/// production (the parent is our own subdirectory of
502+
/// $XDG_RUNTIME_DIR) and impossible in a test that puts the socket
503+
/// straight into a shared /tmp: chmodding a directory you do not own
504+
/// fails with EPERM, so every one of these tests died with
505+
/// `spawn_at: Backend("Operation not permitted (os error 1)")` on a
506+
/// CI runner while passing on a single-user laptop where /tmp happens
507+
/// to be owned by the test user.
497508
fn temp_socket(name: &str) -> PathBuf {
498-
std::env::temp_dir().join(format!(
499-
"outloud-hotkey-test-{}-{name}-{}.sock",
500-
std::process::id(),
501-
name
502-
))
509+
let dir =
510+
std::env::temp_dir().join(format!("outloud-hotkey-test-{}-{name}", std::process::id()));
511+
std::fs::create_dir_all(&dir).expect("create per-test socket dir");
512+
dir.join(format!("{name}.sock"))
503513
}
504514

505515
/// End-to-end over a real socket: PRESS then RELEASE past the tap

0 commit comments

Comments
 (0)