1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge pull request #6878 from sylvestre/du

du: fix the display with --inodes
This commit is contained in:
Daniel Hofstetter 2024-11-21 10:42:48 +01:00 committed by GitHub
commit e37d2f2a2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 6 deletions

View file

@ -546,6 +546,33 @@ fn test_du_inodes_with_count_links() {
}
}
#[cfg(not(target_os = "android"))]
#[test]
fn test_du_inodes_with_count_links_all() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir("d");
at.mkdir("d/d");
at.touch("d/f");
at.hard_link("d/f", "d/h");
let result = ts.ucmd().arg("--inodes").arg("-al").arg("d").succeeds();
result.no_stderr();
let mut result_seq: Vec<String> = result
.stdout_str()
.split('\n')
.filter(|x| !x.is_empty())
.map(|x| x.parse().unwrap())
.collect();
result_seq.sort_unstable();
#[cfg(windows)]
assert_eq!(result_seq, ["1\td\\d", "1\td\\f", "1\td\\h", "4\td"]);
#[cfg(not(windows))]
assert_eq!(result_seq, ["1\td/d", "1\td/f", "1\td/h", "4\td"]);
}
#[test]
fn test_du_h_flag_empty_file() {
new_ucmd!()
@ -1171,3 +1198,25 @@ fn test_invalid_time_style() {
.succeeds()
.stdout_does_not_contain("du: invalid argument 'banana' for 'time style'");
}
#[test]
fn test_human_size() {
use std::fs::File;
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let dir = at.plus_as_string("d");
at.mkdir(&dir);
for i in 1..=1023 {
let file_path = format!("{dir}/file{i}");
File::create(&file_path).expect("Failed to create file");
}
ts.ucmd()
.arg("--inodes")
.arg("-h")
.arg(&dir)
.succeeds()
.stdout_contains(format!("1.0K {dir}"));
}