mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
process: Add status_async2 as a closer analog to spawn_async
This commit is contained in:
@@ -119,6 +119,7 @@ fn wait_with_output_captures() {
|
||||
assert_eq!(output.stderr.len(), 0);
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[test]
|
||||
fn status_closes_any_pipes() {
|
||||
let mut core = Core::new().unwrap();
|
||||
@@ -136,3 +137,21 @@ fn status_closes_any_pipes() {
|
||||
Err(_) => panic!("failed to run futures"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status2_closes_any_pipes() {
|
||||
let mut core = Core::new().unwrap();
|
||||
|
||||
// Cat will open a pipe between the parent and child.
|
||||
// If `status_async2` doesn't ensure the handles are closed,
|
||||
// we would end up blocking forever (and time out).
|
||||
let child = cat().status_async2(&core.handle()).unwrap();
|
||||
let timeout = Timeout::new(Duration::from_secs(1), &core.handle())
|
||||
.expect("timeout registration failed")
|
||||
.map(|()| panic!("time out exceeded! did we get stuck waiting on the child?"));
|
||||
|
||||
match core.run(child.select(timeout)) {
|
||||
Ok((status, _)) => assert!(status.success()),
|
||||
Err(_) => panic!("failed to run futures"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user