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

split : --filter and stdin updates (#5418)

This commit is contained in:
Yury Zhytkou 2023-10-20 02:47:32 -04:00 committed by GitHub
parent ad6d7e8a67
commit eede467e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 220 additions and 57 deletions

View file

@ -338,6 +338,36 @@ fn test_filter_broken_pipe() {
.succeeds();
}
#[test]
#[cfg(unix)]
fn test_filter_with_kth_chunk() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.args(&["--filter='some'", "--number=1/2"])
.ignore_stdin_write_error()
.pipe_in("a\n")
.fails()
.no_stdout()
.stderr_contains("--filter does not process a chunk extracted to stdout");
scene
.ucmd()
.args(&["--filter='some'", "--number=l/1/2"])
.ignore_stdin_write_error()
.pipe_in("a\n")
.fails()
.no_stdout()
.stderr_contains("--filter does not process a chunk extracted to stdout");
scene
.ucmd()
.args(&["--filter='some'", "--number=r/1/2"])
.ignore_stdin_write_error()
.pipe_in("a\n")
.fails()
.no_stdout()
.stderr_contains("--filter does not process a chunk extracted to stdout");
}
#[test]
fn test_split_lines_number() {
// Test if stdout/stderr for '--lines' option is correct
@ -699,6 +729,24 @@ fn test_split_stdin_num_kth_chunk() {
.stderr_only("split: -: cannot determine file size\n");
}
#[test]
fn test_split_stdin_num_line_chunks() {
new_ucmd!()
.args(&["--number=l/2"])
.fails()
.code_is(1)
.stderr_only("split: -: cannot determine file size\n");
}
#[test]
fn test_split_stdin_num_kth_line_chunk() {
new_ucmd!()
.args(&["--number=l/2/5"])
.fails()
.code_is(1)
.stderr_only("split: -: cannot determine file size\n");
}
fn file_read(at: &AtPath, filename: &str) -> String {
let mut s = String::new();
at.open(filename).read_to_string(&mut s).unwrap();