Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Dec 26, 2023
1 parent fc7261a commit 6efa1f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ pub fn div_ceil(a: u64, b: u64) -> u64 {
(a + b - 1) / b
}

// Read file paths from the specified file, separated by null characters
fn read_files_from(file_name: &str) -> Result<Vec<PathBuf>, std::io::Error> {
let reader: Box<dyn BufRead> = if file_name == "-" {
// Read from standard input
Expand Down Expand Up @@ -656,7 +657,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.into());
}

// Read file paths from the specified file, separated by null characters
read_files_from(file_from)?
} else {
match matches.get_one::<String>(options::FILE) {
Expand Down
13 changes: 13 additions & 0 deletions tests/by-util/test_du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,3 +992,16 @@ fn test_du_files0_from_dir() {
let result = ts.ucmd().arg("--files0-from=dir").fails();
assert_eq!(result.stderr_str(), "du: dir: read error: Is a directory\n");
}

#[test]
fn test_du_files0_from_combined() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;

at.mkdir("dir");

let result = ts.ucmd().arg("--files0-from=-").arg("foo").fails();
let stderr = result.stderr_str();

assert!(stderr.contains("file operands cannot be combined with --files0-from"));
}

0 comments on commit 6efa1f9

Please sign in to comment.