Merge pull request #8338 from sylvestre/du-inode

du: create the string into the main thread to avoid some translations issue
This commit is contained in:
Daniel Hofstetter
2025-07-14 13:42:54 +02:00
committed by GitHub
2 changed files with 25 additions and 5 deletions
+3 -5
View File
@@ -92,6 +92,7 @@ struct StatPrinter {
time_format: String,
line_ending: LineEnding,
summarize: bool,
total_text: String,
}
#[derive(PartialEq, Clone)]
@@ -546,11 +547,7 @@ impl StatPrinter {
}
if self.total {
print!(
"{}\t{}",
self.convert_size(grand_total),
get_message("du-total")
);
print!("{}\t{}", self.convert_size(grand_total), self.total_text);
print!("{}", self.line_ending);
}
@@ -779,6 +776,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
time,
time_format,
line_ending: LineEnding::from_zero_flag(matches.get_flag(options::NULL)),
total_text: get_message("du-total"),
};
if stat_printer.inodes
+22
View File
@@ -1295,3 +1295,25 @@ fn test_du_inodes_blocksize_ineffective() {
);
}
}
#[test]
fn test_du_inodes_total_text() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir_all("d/d");
let result = ts.ucmd().arg("--inodes").arg("-c").arg("d").succeeds();
let lines: Vec<&str> = result.stdout_str().lines().collect();
assert_eq!(lines.len(), 3);
let total_line = lines.last().unwrap();
assert!(total_line.contains("total"));
let parts: Vec<&str> = total_line.split('\t').collect();
assert_eq!(parts.len(), 2);
assert!(parts[0].parse::<u64>().is_ok());
}