mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tac: Flush BufWriter
This commit is contained in:
@@ -164,6 +164,7 @@ fn buffer_tac_regex(
|
||||
// After the loop terminates, write whatever bytes are remaining at
|
||||
// the beginning of the buffer.
|
||||
out.write_all(&data[0..following_line_start])?;
|
||||
out.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -215,6 +216,7 @@ fn buffer_tac(data: &[u8], before: bool, separator: &str) -> std::io::Result<()>
|
||||
// After the loop terminates, write whatever bytes are remaining at
|
||||
// the beginning of the buffer.
|
||||
out.write_all(&data[0..following_line_start])?;
|
||||
out.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user