1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #7622 from blyxxyz/flush-bufwriters

Flush `BufWriter`s, clean up error reporting
This commit is contained in:
Terts Diepraam 2025-04-08 20:52:51 +02:00 committed by GitHub
commit 8040305715
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 173 additions and 63 deletions

View file

@ -375,3 +375,15 @@ fn test_output_delimiter_with_adjacent_ranges() {
.succeeds()
.stdout_only("ab:cd\n");
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.arg("-d=")
.arg("-f1")
.pipe_in("key=value")
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("cut: write error: No space left on device\n");
}

View file

@ -163,3 +163,14 @@ fn test_format() {
.succeeds()
.stdout_only("\\xx {}{}{a}{}{}\n");
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.arg("-G")
.pipe_in("hello")
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("ptx: write failed: No space left on device\n");
}

View file

@ -1335,3 +1335,13 @@ fn test_human_blocks_r_and_q() {
fn test_args_check_conflict() {
new_ucmd!().arg("-c").arg("-C").fails();
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.pipe_in("hello")
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("sort: write failed: 'standard output': No space left on device\n");
}

View file

@ -309,3 +309,13 @@ fn test_regex_before() {
// |--------||----||---|
.stdout_is("+---+c+d-e+--++b+-+a+");
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.pipe_in("hello")
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("tac: failed to write to stdout: No space left on device (os error 28)\n");
}

View file

@ -4843,3 +4843,13 @@ fn test_child_when_run_with_stderr_to_stdout() {
.fails()
.stdout_only(expected_stdout);
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.pipe_in("hello")
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("tail: No space left on device\n");
}

View file

@ -1545,3 +1545,14 @@ fn test_non_digit_repeat() {
.fails()
.stderr_only("tr: invalid repeat count 'c' in [c*n] construct\n");
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.pipe_in("hello")
.args(&["e", "a"])
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("tr: write error: No space left on device\n");
}

View file

@ -1181,3 +1181,14 @@ fn test_stdin_w1_multibyte() {
.succeeds()
.stdout_is("à\ná\n");
}
#[cfg(target_os = "linux")]
#[test]
fn test_failed_write_is_reported() {
new_ucmd!()
.pipe_in("hello")
.args(&["-z"])
.set_stdout(std::fs::File::create("/dev/full").unwrap())
.fails()
.stderr_is("uniq: write error: No space left on device\n");
}