Files
tokio/tokio-process/tests/support/mod.rs
T
Ivan Petkov cb2336ff3d process: Misc polish (#1400)
* Denied all warnings in tests, and denied rust_2018_idioms violations
* Bumped the crate version and set publish = false
* Pruned dependencies:
 - Only pull in tokio-sync on windows where it is used
 - Removed unused dev-dependencies
* Switch to Async{Read, Write} traits from tokio-io rather than
futures-io
* Use #[tokio::test] where possible
* Removed deprecated items
* Fix all doc examples
2019-08-07 10:38:45 -07:00

30 lines
690 B
Rust

#![deny(warnings, rust_2018_idioms)]
use futures_util::future;
use futures_util::future::FutureExt;
use std::env;
use std::future::Future;
use std::process::Command;
use std::time::Duration;
use tokio::timer::Timeout;
#[allow(dead_code)]
pub fn cmd(s: &str) -> Command {
let mut me = env::current_exe().unwrap();
me.pop();
if me.ends_with("deps") {
me.pop();
}
me.push(s);
Command::new(me)
}
pub fn with_timeout<F: Future>(future: F) -> impl Future<Output = F::Output> {
Timeout::new(future, Duration::from_secs(3)).then(|r| {
if r.is_err() {
panic!("timed out {:?}", r.err());
}
future::ready(r.unwrap())
})
}