2021-11-25 23:36:17 +01:00
|
|
|
use std::io::Write;
|
|
|
|
use executor::run::run;
|
2021-11-14 17:51:48 +01:00
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
2021-11-25 23:36:17 +01:00
|
|
|
use executor::prelude::{ProcStack, spawn};
|
2021-11-14 17:51:48 +01:00
|
|
|
|
|
|
|
#[cfg(feature = "tokio-runtime")]
|
|
|
|
mod tokio_tests {
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_run_blocking() {
|
|
|
|
super::run_test()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(feature = "tokio-runtime"))]
|
|
|
|
mod no_tokio_tests {
|
|
|
|
#[test]
|
|
|
|
fn test_run_blocking() {
|
|
|
|
super::run_test()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_test() {
|
2021-11-25 23:36:17 +01:00
|
|
|
let handle = spawn(
|
|
|
|
async {
|
|
|
|
let duration = Duration::from_millis(1);
|
|
|
|
thread::sleep(duration);
|
|
|
|
//42
|
|
|
|
},
|
|
|
|
);
|
2021-11-14 17:51:48 +01:00
|
|
|
|
2021-11-25 23:36:17 +01:00
|
|
|
let output = run(handle, ProcStack {});
|
|
|
|
|
|
|
|
println!("{:?}", output);
|
|
|
|
std::io::stdout().flush();
|
|
|
|
assert!(output.is_some());
|
|
|
|
std::thread::sleep(Duration::from_millis(200));
|
2021-11-14 17:51:48 +01:00
|
|
|
}
|