diff options
Diffstat (limited to 'tests-integration/src')
-rw-r--r-- | tests-integration/src/bin/test-cat.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests-integration/src/bin/test-cat.rs b/tests-integration/src/bin/test-cat.rs new file mode 100644 index 00000000..3b30bf18 --- /dev/null +++ b/tests-integration/src/bin/test-cat.rs @@ -0,0 +1,20 @@ +//! A cat-like utility that can be used as a subprocess to test I/O +//! stream communication. + +use std::io; +use std::io::Write; + +fn main() { + let stdin = io::stdin(); + let mut stdout = io::stdout(); + let mut line = String::new(); + loop { + line.clear(); + stdin.read_line(&mut line).unwrap(); + if line.is_empty() { + break; + } + stdout.write_all(line.as_bytes()).unwrap(); + } + stdout.flush().unwrap(); +} |