File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ impl Uniq {
110110 {
111111 write_line_terminator ! ( writer, line_terminator) ?;
112112 }
113+ writer. flush ( ) . map_err_context ( || "write error" . into ( ) ) ?;
113114 Ok ( ( ) )
114115 }
115116
@@ -226,7 +227,7 @@ impl Uniq {
226227 } else {
227228 writer. write_all ( line)
228229 }
229- . map_err_context ( || "Failed to write line " . to_string ( ) ) ?;
230+ . map_err_context ( || "write error " . to_string ( ) ) ?;
230231
231232 write_line_terminator ! ( writer, line_terminator)
232233 }
Original file line number Diff line number Diff line change @@ -1181,3 +1181,16 @@ fn test_stdin_w1_multibyte() {
11811181 . succeeds ( )
11821182 . stdout_is ( "à\n á\n " ) ;
11831183}
1184+
1185+ #[ cfg( target_os = "linux" ) ]
1186+ #[ test]
1187+ fn test_failed_write_is_reported ( ) {
1188+ use std:: fs:: File ;
1189+
1190+ new_ucmd ! ( )
1191+ . pipe_in ( "hello" )
1192+ . args ( & [ "-z" ] )
1193+ . set_stdout ( File :: create ( "/dev/full" ) . unwrap ( ) )
1194+ . fails ( )
1195+ . stderr_is ( "uniq: write error: No space left on device\n " ) ;
1196+ }
You can’t perform that action at this time.
0 commit comments