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

Merge pull request #2450 from jhscheer/id_refactor_identifier

id: refactor identifiers
This commit is contained in:
Sylvestre Ledru 2021-06-23 19:05:57 +02:00 committed by GitHub
commit 44c770d234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -13,11 +13,11 @@
// http://www.opensource.apple.com/source/shell_cmds/shell_cmds-118/id/id.c // http://www.opensource.apple.com/source/shell_cmds/shell_cmds-118/id/id.c
// //
// * This was partially rewritten in order for stdout/stderr/exit_code // * This was partially rewritten in order for stdout/stderr/exit_code
// to be conform with GNU coreutils (8.32) testsuite for `id`. // to be conform with GNU coreutils (8.32) test suite for `id`.
// //
// * This supports multiple users (a feature that was introduced in coreutils 8.31) // * This supports multiple users (a feature that was introduced in coreutils 8.31)
// //
// * This passes GNU's coreutils Testsuite (8.32) // * This passes GNU's coreutils Test suite (8.32)
// for "tests/id/uid.sh" and "tests/id/zero/sh". // for "tests/id/uid.sh" and "tests/id/zero/sh".
// //
// * Option '--zero' does not exist for BSD's `id`, therefore '--zero' is only // * Option '--zero' does not exist for BSD's `id`, therefore '--zero' is only
@ -26,7 +26,7 @@
// * Help text based on BSD's `id` manpage and GNU's `id` manpage. // * Help text based on BSD's `id` manpage and GNU's `id` manpage.
// //
// spell-checker:ignore (ToDO) asid auditid auditinfo auid cstr egid emod euid getaudit getlogin gflag nflag pline rflag termid uflag gsflag zflag testsuite // spell-checker:ignore (ToDO) asid auditid auditinfo auid cstr egid emod euid getaudit getlogin gflag nflag pline rflag termid uflag gsflag zflag
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(dead_code)] #![allow(dead_code)]
@ -242,7 +242,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
crash!(1, "cannot print only names or real IDs in default format"); crash!(1, "cannot print only names or real IDs in default format");
} }
if (state.zflag) && default_format { if (state.zflag) && default_format {
// NOTE: GNU testsuite "id/zero.sh" needs this stderr output: // NOTE: GNU test suite "id/zero.sh" needs this stderr output:
crash!(1, "option --zero not permitted in default format"); crash!(1, "option --zero not permitted in default format");
} }

View file

@ -1,6 +1,6 @@
use crate::common::util::*; use crate::common::util::*;
// spell-checker:ignore (ToDO) testsuite coreutil // spell-checker:ignore (ToDO) coreutil
// These tests run the GNU coreutils `(g)id` binary in `$PATH` in order to gather reference values. // These tests run the GNU coreutils `(g)id` binary in `$PATH` in order to gather reference values.
// If the `(g)id` in `$PATH` doesn't include a coreutils version string, // If the `(g)id` in `$PATH` doesn't include a coreutils version string,
@ -8,8 +8,8 @@ use crate::common::util::*;
// The reference version is 8.32. Here 8.30 was chosen because right now there's no // The reference version is 8.32. Here 8.30 was chosen because right now there's no
// ubuntu image for github action available with a higher version than 8.30. // ubuntu image for github action available with a higher version than 8.30.
const VERSION_EXPECTED: &str = "8.30"; // Version expected for the reference `id` in $PATH const VERSION_MIN: &str = "8.30"; // minimum Version for the reference `id` in $PATH
const VERSION_MULTIPLE_USERS: &str = "8.31"; const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
const UUTILS_WARNING: &str = "uutils-tests-warning"; const UUTILS_WARNING: &str = "uutils-tests-warning";
const UUTILS_INFO: &str = "uutils-tests-info"; const UUTILS_INFO: &str = "uutils-tests-info";
@ -210,13 +210,13 @@ fn test_id_multiple_users() {
let util_name = util_name!(); let util_name = util_name!();
#[cfg(all(unix, not(target_os = "linux")))] #[cfg(all(unix, not(target_os = "linux")))]
let util_name = &format!("g{}", util_name!()); let util_name = &format!("g{}", util_name!());
let version_check_string = check_coreutil_version(util_name, VERSION_MULTIPLE_USERS); let version_check_string = check_coreutil_version(util_name, VERSION_MIN_MULTIPLE_USERS);
if version_check_string.starts_with(UUTILS_WARNING) { if version_check_string.starts_with(UUTILS_WARNING) {
println!("{}\ntest skipped", version_check_string); println!("{}\ntest skipped", version_check_string);
return; return;
} }
// Same typical users that GNU testsuite is using. // Same typical users that GNU test suite is using.
let test_users = ["root", "man", "postfix", "sshd", &whoami()]; let test_users = ["root", "man", "postfix", "sshd", &whoami()];
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
@ -278,7 +278,7 @@ fn test_id_multiple_users_non_existing() {
let util_name = util_name!(); let util_name = util_name!();
#[cfg(all(unix, not(target_os = "linux")))] #[cfg(all(unix, not(target_os = "linux")))]
let util_name = &format!("g{}", util_name!()); let util_name = &format!("g{}", util_name!());
let version_check_string = check_coreutil_version(util_name, VERSION_MULTIPLE_USERS); let version_check_string = check_coreutil_version(util_name, VERSION_MIN_MULTIPLE_USERS);
if version_check_string.starts_with(UUTILS_WARNING) { if version_check_string.starts_with(UUTILS_WARNING) {
println!("{}\ntest skipped", version_check_string); println!("{}\ntest skipped", version_check_string);
return; return;
@ -467,7 +467,7 @@ fn expected_result(args: &[&str]) -> Result<CmdResult, String> {
#[cfg(all(unix, not(target_os = "linux")))] #[cfg(all(unix, not(target_os = "linux")))]
let util_name = &format!("g{}", util_name!()); let util_name = &format!("g{}", util_name!());
let version_check_string = check_coreutil_version(util_name, VERSION_EXPECTED); let version_check_string = check_coreutil_version(util_name, VERSION_MIN);
if version_check_string.starts_with(UUTILS_WARNING) { if version_check_string.starts_with(UUTILS_WARNING) {
return Err(version_check_string); return Err(version_check_string);
} }