1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 22:17:45 +00:00

Merge branch 'master' into refactoring_parse_size

This commit is contained in:
Jan Scheer 2021-06-12 02:24:07 +02:00
commit 39f5f70f2b
63 changed files with 537 additions and 683 deletions

View file

@ -334,3 +334,20 @@ fn _du_no_permission(s: &str) {
fn _du_no_permission(s: &str) {
assert_eq!(s, "4\tsubdir/links\n");
}
#[test]
fn test_du_one_file_system() {
let scene = TestScenario::new(util_name!());
let result = scene.ucmd().arg("-x").arg(SUB_DIR).succeeds();
#[cfg(target_os = "linux")]
{
let result_reference = scene.cmd("du").arg("-x").arg(SUB_DIR).run();
if result_reference.succeeded() {
assert_eq!(result.stdout_str(), result_reference.stdout_str());
return;
}
}
_du_basics_subdir(result.stdout_str());
}

View file

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

View file

@ -69,6 +69,22 @@ pub struct CmdResult {
}
impl CmdResult {
pub fn new(
tmpd: Option<Rc<TempDir>>,
code: Option<i32>,
success: bool,
stdout: &[u8],
stderr: &[u8],
) -> CmdResult {
CmdResult {
tmpd,
code,
success,
stdout: stdout.to_vec(),
stderr: stderr.to_vec(),
}
}
/// Returns a reference to the program's standard output as a slice of bytes
pub fn stdout(&self) -> &[u8] {
&self.stdout