mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge branch 'master' into id_zero_2351
This commit is contained in:
commit
babf6ecae4
19 changed files with 461 additions and 165 deletions
|
@ -112,28 +112,23 @@ fn test_id_group() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||
fn test_id_groups() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
||||
let result = scene.ucmd().arg("-G").succeeds();
|
||||
let groups = result.stdout_str().trim().split_whitespace();
|
||||
for s in groups {
|
||||
assert!(s.parse::<u64>().is_ok());
|
||||
}
|
||||
|
||||
let result = scene.ucmd().arg("--groups").succeeds();
|
||||
let groups = result.stdout_str().trim().split_whitespace();
|
||||
for s in groups {
|
||||
assert!(s.parse::<u64>().is_ok());
|
||||
}
|
||||
|
||||
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||
for args in &["-G", "--groups"] {
|
||||
let expect = expected_result(&[args], false);
|
||||
let actual = new_ucmd!().arg(&args).succeeds().stdout_move_str();
|
||||
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
||||
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
||||
assert_eq!(v_actual.sort_unstable(), v_expect.sort_unstable());
|
||||
for g_flag in &["-G", "--groups"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(g_flag)
|
||||
.succeeds()
|
||||
.stdout_is(expected_result(&[g_flag], false));
|
||||
for &r_flag in &["-r", "--real"] {
|
||||
let args = [g_flag, r_flag];
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&args)
|
||||
.succeeds()
|
||||
.stdout_is(expected_result(&args, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,26 +191,28 @@ fn test_id_password_style() {
|
|||
#[test]
|
||||
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||
fn test_id_default_format() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
// -ugG
|
||||
for flag in &["--name", "--real"] {
|
||||
new_ucmd!()
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(flag)
|
||||
.fails()
|
||||
.stderr_is(expected_result(&[flag], true));
|
||||
for &opt in &["--user", "--group", "--groups"] {
|
||||
if is_ci() && *flag == "--name" {
|
||||
// '--name' does not work in CI:
|
||||
// '--name' does not work on CICD ubuntu-16/ubuntu-18
|
||||
// id: cannot find name for user ID 1001
|
||||
// id: cannot find name for group ID 116
|
||||
println!("test skipped:");
|
||||
println!("test skipped");
|
||||
continue;
|
||||
}
|
||||
let args = [opt, flag];
|
||||
let expect = expected_result(&args, false);
|
||||
let actual = new_ucmd!().args(&args).succeeds().stdout_move_str();
|
||||
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
||||
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
||||
assert_eq!(v_actual.sort_unstable(), v_expect.sort_unstable());
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&args)
|
||||
.succeeds()
|
||||
.stdout_is(expected_result(&args, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,21 +228,13 @@ fn test_id_zero() {
|
|||
.fails()
|
||||
.stderr_is(expected_result(&args, true));
|
||||
}
|
||||
for &opt in &["-u", "--user", "-g", "--group"] {
|
||||
for &opt in &["-u", "--user", "-g", "--group", "-G", "--groups"] {
|
||||
let args = [opt, z_flag];
|
||||
new_ucmd!()
|
||||
.args(&args)
|
||||
.succeeds()
|
||||
.stdout_is(expected_result(&args, false));
|
||||
}
|
||||
// '--groups' ids are in no particular order and when paired with '--zero' there's no
|
||||
// delimiter which makes the split_whitespace-collect-into-vector comparison impossible.
|
||||
for opt in &["-G", "--groups"] {
|
||||
let args = [opt, z_flag];
|
||||
let result = new_ucmd!().args(&args).succeeds().stdout_move_str();
|
||||
assert!(!result.contains(" "));
|
||||
assert!(result.ends_with('\0'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +260,6 @@ fn expected_result(args: &[&str], exp_fail: bool) -> String {
|
|||
.fails()
|
||||
.stderr_move_str()
|
||||
};
|
||||
// #[cfg(target_vendor = "apple")]
|
||||
return if cfg!(target_os = "macos") && result.starts_with("gid") {
|
||||
result[1..].to_string()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue