Skip to content

Commit d9acf29

Browse files
authored
Merge pull request #262 from cakebaker/w_fix_unresolved_imports_on_macos
pgrep, w: make tests linux-only
2 parents 2c4a5dd + 0d5ff87 commit d9acf29

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/uu/pgrep/src/process.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ pub fn walk_process() -> impl Iterator<Item = ProcessInformation> {
381381
#[cfg(test)]
382382
mod tests {
383383
use super::*;
384+
#[cfg(target_os = "linux")]
384385
use std::{collections::HashSet, str::FromStr};
385386

386387
#[test]
@@ -398,6 +399,7 @@ mod tests {
398399
assert!(RunState::try_from("Rg").is_err());
399400
}
400401

402+
#[cfg(target_os = "linux")]
401403
fn current_pid() -> usize {
402404
// Direct read link of /proc/self.
403405
// It's result must be current programs pid.
@@ -410,6 +412,7 @@ mod tests {
410412
}
411413

412414
#[test]
415+
#[cfg(target_os = "linux")]
413416
fn test_walk_pid() {
414417
let current_pid = current_pid();
415418

@@ -419,6 +422,7 @@ mod tests {
419422
}
420423

421424
#[test]
425+
#[cfg(target_os = "linux")]
422426
fn test_pid_entry() {
423427
let current_pid = current_pid();
424428

src/uu/w/src/w.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ pub fn uu_app() -> Command {
257257
}
258258

259259
#[cfg(test)]
260+
#[cfg(target_os = "linux")]
260261
mod tests {
261262
use crate::{
262263
fetch_cmdline, fetch_pcpu_time, fetch_terminal_number, format_time, get_clock_tick,
263264
};
264265
use std::{fs, path::Path, process};
265266

266267
#[test]
267-
#[cfg(target_os = "linux")]
268268
fn test_format_time() {
269269
let unix_epoc = chrono::Local::now()
270270
.format("%Y-%m-%d %H:%M:%S%.6f %::z")
@@ -284,7 +284,6 @@ mod tests {
284284
}
285285

286286
#[test]
287-
#[cfg(target_os = "linux")]
288287
// Get PID of current process and use that for cmdline testing
289288
fn test_fetch_cmdline() {
290289
// uucore's utmpx returns an i32, so we cast to that to mimic it.
@@ -297,7 +296,6 @@ mod tests {
297296
}
298297

299298
#[test]
300-
#[cfg(target_os = "linux")]
301299
fn test_fetch_terminal_number() {
302300
let pid = process::id() as i32;
303301
let path = Path::new("/proc").join(pid.to_string()).join("stat");
@@ -308,7 +306,6 @@ mod tests {
308306
}
309307

310308
#[test]
311-
#[cfg(target_os = "linux")]
312309
fn test_fetch_pcpu_time() {
313310
let pid = process::id() as i32;
314311
let path = Path::new("/proc").join(pid.to_string()).join("stat");

0 commit comments

Comments
 (0)