mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
who freebsd build fix unsupported RUN_LVL option only for other platforms.
This commit is contained in:
committed by
David CARLIER
parent
542deb8888
commit
fcb079e20e
+11
-6
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user