1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

Merge pull request #2373 from tertsdiepraam/groups/use-id-in-tests

`groups`: fix test for Arch-based systems
This commit is contained in:
Sylvestre Ledru 2021-06-09 22:44:51 +02:00 committed by GitHub
commit def5bec1ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
use crate::common::util::*; use crate::common::util::*;
#[test] #[test]
#[cfg(any(target_vendor = "apple", target_os = "linux"))] #[cfg(unix)]
fn test_groups() { fn test_groups() {
if !is_ci() { if !is_ci() {
new_ucmd!().succeeds().stdout_is(expected_result(&[])); new_ucmd!().succeeds().stdout_is(expected_result(&[]));
@ -13,7 +13,7 @@ fn test_groups() {
} }
#[test] #[test]
#[cfg(any(target_os = "linux"))] #[cfg(unix)]
#[ignore = "fixme: 'groups USERNAME' needs more debugging"] #[ignore = "fixme: 'groups USERNAME' needs more debugging"]
fn test_groups_username() { fn test_groups_username() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
@ -37,17 +37,20 @@ fn test_groups_username() {
.stdout_is(expected_result(&[&username])); .stdout_is(expected_result(&[&username]));
} }
#[cfg(any(target_vendor = "apple", target_os = "linux"))] #[cfg(unix)]
fn expected_result(args: &[&str]) -> String { fn expected_result(args: &[&str]) -> String {
#[cfg(target_os = "linux")] // We want to use GNU id. On most linux systems, this is "id", but on
let util_name = util_name!(); // bsd-like systems (e.g. FreeBSD, MacOS), it is commonly "gid".
#[cfg(target_vendor = "apple")] #[cfg(any(target_os = "linux"))]
let util_name = format!("g{}", util_name!()); let util_name = "id";
#[cfg(not(target_os = "linux"))]
let util_name = "gid";
TestScenario::new(&util_name) TestScenario::new(util_name)
.cmd_keepenv(util_name) .cmd_keepenv(util_name)
.env("LANGUAGE", "C") .env("LANGUAGE", "C")
.args(args) .args(args)
.args(&["-Gn"])
.succeeds() .succeeds()
.stdout_move_str() .stdout_move_str()
} }