-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
uucore: fix order of group IDs return from entries::get_groups() #2371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,53 @@ | ||
| use crate::common::util::*; | ||
|
|
||
| #[test] | ||
| #[cfg(any(target_vendor = "apple", target_os = "linux"))] | ||
| fn test_groups() { | ||
| let result = new_ucmd!().run(); | ||
| println!("result.stdout = {}", result.stdout_str()); | ||
| println!("result.stderr = {}", result.stderr_str()); | ||
| if is_ci() && result.stdout_str().trim().is_empty() { | ||
| // In the CI, some server are failing to return the group. | ||
| // As seems to be a configuration issue, ignoring it | ||
| return; | ||
| if !is_ci() { | ||
| new_ucmd!().succeeds().stdout_is(expected_result(&[])); | ||
| } else { | ||
| // TODO: investigate how this could be tested in CI | ||
| // stderr = groups: cannot find name for group ID 116 | ||
| println!("test skipped:"); | ||
| } | ||
| result.success(); | ||
| assert!(!result.stdout_str().trim().is_empty()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_groups_arg() { | ||
| // get the username with the "id -un" command | ||
| let result = TestScenario::new("id").ucmd_keepenv().arg("-un").run(); | ||
| println!("result.stdout = {}", result.stdout_str()); | ||
| println!("result.stderr = {}", result.stderr_str()); | ||
| let s1 = String::from(result.stdout_str().trim()); | ||
| if is_ci() && s1.parse::<f64>().is_ok() { | ||
| // In the CI, some server are failing to return id -un. | ||
| // So, if we are getting a uid, just skip this test | ||
| // As seems to be a configuration issue, ignoring it | ||
| #[cfg(any(target_os = "linux"))] | ||
| #[ignore = "fixme: 'groups USERNAME' needs more debugging"] | ||
jhscheer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fn test_groups_username() { | ||
| let scene = TestScenario::new(util_name!()); | ||
| let whoami_result = scene.cmd("whoami").run(); | ||
jhscheer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| let username = if whoami_result.succeeded() { | ||
| whoami_result.stdout_move_str() | ||
| } else if is_ci() { | ||
| String::from("docker") | ||
| } else { | ||
| println!("test skipped:"); | ||
| return; | ||
| } | ||
| }; | ||
|
|
||
| // TODO: stdout should be in the form: "username : group1 group2 group3" | ||
|
|
||
| scene | ||
| .ucmd() | ||
| .arg(&username) | ||
| .succeeds() | ||
| .stdout_is(expected_result(&[&username])); | ||
| } | ||
|
|
||
| println!("result.stdout = {}", result.stdout_str()); | ||
| println!("result.stderr = {}", result.stderr_str()); | ||
| result.success(); | ||
| assert!(!result.stdout_str().is_empty()); | ||
| let username = result.stdout_str().trim(); | ||
| #[cfg(any(target_vendor = "apple", target_os = "linux"))] | ||
| fn expected_result(args: &[&str]) -> String { | ||
| #[cfg(target_os = "linux")] | ||
| let util_name = util_name!(); | ||
| #[cfg(target_vendor = "apple")] | ||
| let util_name = format!("g{}", util_name!()); | ||
|
|
||
| // call groups with the user name to check that we | ||
| // are getting something | ||
| new_ucmd!().arg(username).succeeds(); | ||
| assert!(!result.stdout_str().is_empty()); | ||
| TestScenario::new(&util_name) | ||
| .cmd_keepenv(util_name) | ||
| .env("LANGUAGE", "C") | ||
| .args(args) | ||
| .succeeds() | ||
| .stdout_move_str() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.