1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

who freebsd build fix unsupported RUN_LVL option only for other platforms.

This commit is contained in:
David Carlier 2021-05-20 20:09:41 +01:00 committed by David CARLIER
parent 542deb8888
commit fcb079e20e
2 changed files with 27 additions and 7 deletions

View file

@ -29,7 +29,7 @@ mod options {
pub const ONLY_HOSTNAME_USER: &str = "only_hostname_user"; pub const ONLY_HOSTNAME_USER: &str = "only_hostname_user";
pub const PROCESS: &str = "process"; pub const PROCESS: &str = "process";
pub const COUNT: &str = "count"; pub const COUNT: &str = "count";
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub const RUNLEVEL: &str = "runlevel"; pub const RUNLEVEL: &str = "runlevel";
pub const SHORT: &str = "short"; pub const SHORT: &str = "short";
pub const TIME: &str = "time"; pub const TIME: &str = "time";
@ -119,11 +119,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.help("all login names and number of users logged on"), .help("all login names and number of users logged on"),
) )
.arg( .arg(
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
Arg::with_name(options::RUNLEVEL) Arg::with_name(options::RUNLEVEL)
.long(options::RUNLEVEL) .long(options::RUNLEVEL)
.short("r") .short("r")
.help("print current runlevel"), .help("print current runlevel"),
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
Arg::with_name(""),
) )
.arg( .arg(
Arg::with_name(options::SHORT) Arg::with_name(options::SHORT)
@ -265,10 +267,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
assumptions = false; assumptions = false;
} }
if matches.is_present(options::RUNLEVEL) { #[cfg(any(target_os = "linux", target_os = "android"))]
need_runlevel = true; {
include_idle = true; if matches.is_present(options::RUNLEVEL) {
assumptions = false; need_runlevel = true;
include_idle = true;
assumptions = false;
}
} }
if matches.is_present(options::SHORT) { if matches.is_present(options::SHORT) {

View file

@ -83,7 +83,7 @@ fn test_process() {
} }
} }
#[cfg(any(target_vendor = "apple", target_os = "linux"))] #[cfg(target_os = "linux")]
#[test] #[test]
fn test_runlevel() { fn test_runlevel() {
for opt in vec!["-r", "--runlevel"] { for opt in vec!["-r", "--runlevel"] {
@ -94,6 +94,19 @@ fn test_runlevel() {
} }
} }
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
#[test]
fn test_runlevel() {
let expected =
"error: Found argument";
for opt in vec!["-r", "--runlevel"] {
new_ucmd!()
.arg(opt)
.fails()
.stderr_contains(expected);
}
}
#[cfg(any(target_vendor = "apple", target_os = "linux"))] #[cfg(any(target_vendor = "apple", target_os = "linux"))]
#[test] #[test]
fn test_time() { fn test_time() {
@ -122,6 +135,7 @@ fn test_mesg() {
} }
} }
#[cfg(target_os = "linux")]
#[test] #[test]
fn test_arg1_arg2() { fn test_arg1_arg2() {
let args = ["am", "i"]; let args = ["am", "i"];
@ -132,6 +146,7 @@ fn test_arg1_arg2() {
.stdout_is(expected_result(&args)); .stdout_is(expected_result(&args));
} }
#[cfg(target_os = "linux")]
#[test] #[test]
fn test_too_many_args() { fn test_too_many_args() {
const EXPECTED: &str = const EXPECTED: &str =