1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 19:56:17 +00:00

Merge pull request #2966 from allan-silva/wc-files0-from-opt

wc: implement files0-from option
This commit is contained in:
Sylvestre Ledru 2022-02-12 19:05:05 +01:00 committed by GitHub
commit f9e04ae5ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 155 additions and 20 deletions

View file

@ -245,3 +245,57 @@ fn test_files_from_pseudo_filesystem() {
let result = new_ucmd!().arg("-c").arg("/proc/version").succeeds();
assert_ne!(result.stdout_str(), "0 /proc/version\n");
}
#[test]
fn test_files0_disabled_files_argument() {
const MSG: &str = "file operands cannot be combined with --files0-from";
new_ucmd!()
.args(&["--files0-from=files0_list.txt"])
.arg("lorem_ipsum.txt")
.fails()
.stderr_contains(MSG)
.stdout_is("");
}
#[test]
fn test_files0_from() {
new_ucmd!()
.args(&["--files0-from=files0_list.txt"])
.run()
.stdout_is(
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \
alice_in_wonderland.txt\n 36 370 2189 total\n",
);
}
#[test]
fn test_files0_from_with_stdin() {
new_ucmd!()
.args(&["--files0-from=-"])
.pipe_in("lorem_ipsum.txt")
.run()
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
}
#[test]
fn test_files0_from_with_stdin_in_file() {
new_ucmd!()
.args(&["--files0-from=files0_list_with_stdin.txt"])
.pipe_in_fixture("alice_in_wonderland.txt")
.run()
.stdout_is(
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \
-\n 36 370 2189 total\n",
);
}
#[test]
fn test_files0_from_with_stdin_try_read_from_stdin() {
const MSG: &str = "when reading file names from stdin, no file name of '-' allowed";
new_ucmd!()
.args(&["--files0-from=-"])
.pipe_in("-")
.fails()
.stderr_contains(MSG)
.stdout_is("");
}

BIN
tests/fixtures/wc/files0_list.txt vendored Normal file

Binary file not shown.

Binary file not shown.