From 124391e42b0bd6139adbdb182f9ced75ea471bbe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 18 Dec 2016 22:40:14 -0800 Subject: [PATCH] process: Add a simple `wait_with_output` test --- tests/stdio.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/stdio.rs b/tests/stdio.rs index 71d103861..c95fcb4fb 100644 --- a/tests/stdio.rs +++ b/tests/stdio.rs @@ -111,3 +111,21 @@ fn drop_kills() { let err = lp.run(write_all(stdin, b"1234")).err().unwrap(); assert_eq!(err.kind(), io::ErrorKind::BrokenPipe); } + +#[test] +fn wait_with_output_captures() { + let _ = ::env_logger::init(); + + let mut core = Core::new().unwrap(); + + let mut child = cat().spawn_async(&core.handle()).unwrap(); + let stdin = child.stdin().take().unwrap(); + let out = child.wait_with_output(); + + let ret = core.run(write_all(stdin, b"1234").map(|p| p.1).join(out)).unwrap(); + let (written, output) = ret; + + assert!(output.status.success()); + assert_eq!(output.stdout, written); + assert_eq!(output.stderr.len(), 0); +}