Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct StatPrinter {
time_format: String,
line_ending: LineEnding,
summarize: bool,
total_text: String,
}

#[derive(PartialEq, Clone)]
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tests/by-util/test_du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Loading