From 96b72ae03864f1fbf8c32276e9e5734c8d696802 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 3 Nov 2024 14:37:33 +0100 Subject: [PATCH 1/2] w: make test module linux-only --- src/uu/w/src/w.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/uu/w/src/w.rs b/src/uu/w/src/w.rs index 5f96500..6ba4d55 100644 --- a/src/uu/w/src/w.rs +++ b/src/uu/w/src/w.rs @@ -257,6 +257,7 @@ pub fn uu_app() -> Command { } #[cfg(test)] +#[cfg(target_os = "linux")] mod tests { use crate::{ fetch_cmdline, fetch_pcpu_time, fetch_terminal_number, format_time, get_clock_tick, @@ -264,7 +265,6 @@ mod tests { use std::{fs, path::Path, process}; #[test] - #[cfg(target_os = "linux")] fn test_format_time() { let unix_epoc = chrono::Local::now() .format("%Y-%m-%d %H:%M:%S%.6f %::z") @@ -284,7 +284,6 @@ mod tests { } #[test] - #[cfg(target_os = "linux")] // Get PID of current process and use that for cmdline testing fn test_fetch_cmdline() { // uucore's utmpx returns an i32, so we cast to that to mimic it. @@ -297,7 +296,6 @@ mod tests { } #[test] - #[cfg(target_os = "linux")] fn test_fetch_terminal_number() { let pid = process::id() as i32; let path = Path::new("/proc").join(pid.to_string()).join("stat"); @@ -308,7 +306,6 @@ mod tests { } #[test] - #[cfg(target_os = "linux")] fn test_fetch_pcpu_time() { let pid = process::id() as i32; let path = Path::new("/proc").join(pid.to_string()).join("stat"); From 0d5ff87b6cb35cf84a15438bc60a5a19a13ffeb1 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 12 Nov 2024 09:48:21 +0100 Subject: [PATCH 2/2] pgrep: make two tests linux-only --- src/uu/pgrep/src/process.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/uu/pgrep/src/process.rs b/src/uu/pgrep/src/process.rs index c903f25..46fa407 100644 --- a/src/uu/pgrep/src/process.rs +++ b/src/uu/pgrep/src/process.rs @@ -381,6 +381,7 @@ pub fn walk_process() -> impl Iterator { #[cfg(test)] mod tests { use super::*; + #[cfg(target_os = "linux")] use std::{collections::HashSet, str::FromStr}; #[test] @@ -398,6 +399,7 @@ mod tests { assert!(RunState::try_from("Rg").is_err()); } + #[cfg(target_os = "linux")] fn current_pid() -> usize { // Direct read link of /proc/self. // It's result must be current programs pid. @@ -410,6 +412,7 @@ mod tests { } #[test] + #[cfg(target_os = "linux")] fn test_walk_pid() { let current_pid = current_pid(); @@ -419,6 +422,7 @@ mod tests { } #[test] + #[cfg(target_os = "linux")] fn test_pid_entry() { let current_pid = current_pid();