mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
test(cat): add test for output appending to input file
This commit is contained in:
parent
c9312eba9a
commit
9a88526867
1 changed files with 22 additions and 0 deletions
|
@ -9,6 +9,8 @@ use crate::common::util::vec_of_size;
|
||||||
use crate::common::util::TestScenario;
|
use crate::common::util::TestScenario;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use rlimit::Resource;
|
use rlimit::Resource;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use std::fs::File;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
@ -646,3 +648,23 @@ fn test_u_ignored() {
|
||||||
.stdout_only("hello");
|
.stdout_only("hello");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn test_appending_same_input_output() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
|
at.write("foo", "content");
|
||||||
|
let foo_file = at.plus_as_string("foo");
|
||||||
|
|
||||||
|
let file_read = File::open(&foo_file).unwrap();
|
||||||
|
let file_write = OpenOptions::new().append(true).open(&foo_file).unwrap();
|
||||||
|
|
||||||
|
ucmd.set_stdin(file_read);
|
||||||
|
ucmd.set_stdout(file_write);
|
||||||
|
|
||||||
|
ucmd.run()
|
||||||
|
.failure()
|
||||||
|
.no_stdout()
|
||||||
|
.stderr_contains("input file is output file");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue