mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #2239 from devnexen/fbsd_who_build_fix
who freebsd build fix unsupported RUN_LVL option only for other platf…
This commit is contained in:
commit
726f271273
2 changed files with 27 additions and 7 deletions
|
@ -29,7 +29,7 @@ mod options {
|
|||
pub const ONLY_HOSTNAME_USER: &str = "only_hostname_user";
|
||||
pub const PROCESS: &str = "process";
|
||||
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 SHORT: &str = "short";
|
||||
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"),
|
||||
)
|
||||
.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)
|
||||
.long(options::RUNLEVEL)
|
||||
.short("r")
|
||||
.help("print current runlevel"),
|
||||
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||
Arg::with_name(""),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::SHORT)
|
||||
|
@ -265,10 +267,13 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
assumptions = false;
|
||||
}
|
||||
|
||||
if matches.is_present(options::RUNLEVEL) {
|
||||
need_runlevel = true;
|
||||
include_idle = true;
|
||||
assumptions = false;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
{
|
||||
if matches.is_present(options::RUNLEVEL) {
|
||||
need_runlevel = true;
|
||||
include_idle = true;
|
||||
assumptions = false;
|
||||
}
|
||||
}
|
||||
|
||||
if matches.is_present(options::SHORT) {
|
||||
|
|
|
@ -83,7 +83,7 @@ fn test_process() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_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"))]
|
||||
#[test]
|
||||
fn test_time() {
|
||||
|
@ -122,6 +135,7 @@ fn test_mesg() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_arg1_arg2() {
|
||||
let args = ["am", "i"];
|
||||
|
@ -132,6 +146,7 @@ fn test_arg1_arg2() {
|
|||
.stdout_is(expected_result(&args));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_too_many_args() {
|
||||
const EXPECTED: &str =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue