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

tee: should match GNU's output if used with /dev/full (#1944)

+ aligned 'tee' output with GNU tee when one of the files is '/dev/full'
+ don't stop tee when one of the outputs fails; just continue and return
error status from tee in the end

Co-authored-by: Ivan Rymarchyk <irymarchyk@arlo.com>
This commit is contained in:
Ivan 2021-03-27 22:02:49 +03:00 committed by GitHub
parent f66a188414
commit 500771c78d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 40 deletions

View file

@ -60,28 +60,31 @@ fn test_tee_append() {
#[test]
#[cfg(target_os = "linux")]
fn test_tee_no_more_writeable_stdout() {
let (_at, mut ucmd) = at_and_ucmd!();
fn test_tee_no_more_writeable_1() {
// equals to 'tee /dev/full out2 <multi_read' call
let (at, mut ucmd) = at_and_ucmd!();
let content = (1..=10)
.map(|x| format!("{}\n", x.to_string()))
.collect::<String>();
let file_out = "tee_file_out";
let _result = ucmd
let result = ucmd
.arg("/dev/full")
.arg(file_out)
.pipe_in(&content[..])
.fails();
// TODO: comment in after https://github.com/uutils/coreutils/issues/1805 is fixed
// assert_eq!(at.read(file_out), content);
// assert!(result.stdout.contains(&content));
// assert!(result.stderr.contains("No space left on device"));
assert_eq!(at.read(file_out), content);
assert!(result.stdout.contains(&content));
assert!(result.stderr.contains("No space left on device"));
}
#[test]
#[cfg(target_os = "linux")]
fn test_tee_no_more_writeable_stdin() {
fn test_tee_no_more_writeable_2() {
// should be equals to 'tee out1 out2 >/dev/full <multi_read' call
// but currently there is no way to redirect stdout to /dev/full
// so this test is disabled
let (_at, mut ucmd) = at_and_ucmd!();
let _content = (1..=10)
.map(|x| format!("{}\n", x.to_string()))