Revert "tests: fix env guard and pipe read for tab dnd"

This reverts commit ce0868582b.
This commit is contained in:
Ashley Wulber 2025-12-19 13:29:22 -05:00
parent fa26e0e241
commit 4bb0d69ce1
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
2 changed files with 14 additions and 27 deletions

View file

@ -881,9 +881,7 @@ mod tests {
impl EnvVarGuard { impl EnvVarGuard {
fn set(key: &'static str, value: &Path) -> Self { fn set(key: &'static str, value: &Path) -> Self {
let original = env::var(key).ok(); let original = env::var(key).ok();
// std::env::{set_var, remove_var} are unsafe on newer toolchains; std::env::set_var(key, value);
// we limit scope here to the test helper that toggles a single key.
unsafe { std::env::set_var(key, value) };
Self { key, original } Self { key, original }
} }
} }
@ -891,9 +889,9 @@ mod tests {
impl Drop for EnvVarGuard { impl Drop for EnvVarGuard {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(ref original) = self.original { if let Some(ref original) = self.original {
unsafe { std::env::set_var(self.key, original) }; std::env::set_var(self.key, original);
} else { } else {
unsafe { std::env::remove_var(self.key) }; std::env::remove_var(self.key);
} }
} }
} }
@ -1110,8 +1108,7 @@ Icon=vmware-workstation\n\
let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default()); let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default());
assert!(resolved.icon().is_some()); assert!(resolved.icon().is_some());
assert!(resolved.exec().is_some()); assert!(resolved.exec().is_some());
let expected = format!("crx_{}", id); assert_eq!(resolved.startup_wm_class(), Some(&format!("crx_{}", id)));
assert_eq!(resolved.startup_wm_class(), Some(expected.as_str()));
} }
#[test] #[test]

View file

@ -9,28 +9,18 @@ use std::process::{Command, Stdio, exit};
#[cfg(feature = "tokio")] #[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
#[cfg(feature = "tokio")]
async fn read_from_pipe(read: OwnedFd) -> Option<u32> { async fn read_from_pipe(read: OwnedFd) -> Option<u32> {
#[cfg(feature = "tokio")] let mut read = tokio::net::unix::pipe::Receiver::from_owned_fd(read).unwrap();
{ read.read_u32().await.ok()
let mut read = tokio::net::unix::pipe::Receiver::from_owned_fd(read).unwrap(); }
return read.read_u32().await.ok();
}
#[cfg(all(feature = "smol", not(feature = "tokio")))] #[cfg(all(feature = "smol", not(feature = "tokio")))]
{ async fn read_from_pipe(read: OwnedFd) -> Option<u32> {
let mut read = smol::Async::new(std::fs::File::from(read)).unwrap(); let mut read = smol::Async::new(std::fs::File::from(read)).unwrap();
let mut bytes = [0; 4]; let mut bytes = [0; 4];
read.read_exact(&mut bytes).await.ok()?; read.read_exact(&mut bytes).await.ok()?;
return Some(u32::from_be_bytes(bytes)); Some(u32::from_be_bytes(bytes))
}
#[cfg(not(any(feature = "tokio", feature = "smol")))]
{
use rustix::fd::AsFd;
let mut bytes = [0u8; 4];
rustix::io::read(&read, &mut bytes).ok()?;
return Some(u32::from_be_bytes(bytes));
}
} }
/// Performs a double fork with setsid to spawn and detach a command. /// Performs a double fork with setsid to spawn and detach a command.