process: Add a simple wait_with_output test

This commit is contained in:
Alex Crichton
2019-06-24 16:56:48 -07:00
committed by Ivan Petkov
parent 6150be189f
commit 124391e42b
+18
View File
@@ -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);
}