mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
better wait for removed_from_resource_table_on_close test (#2104)
This commit is contained in:
parent
e0edcc9c1b
commit
d3bd5879c3
1 changed files with 7 additions and 8 deletions
|
@ -258,7 +258,6 @@ mod tests {
|
|||
use deno::js_check;
|
||||
use futures::future::lazy;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::thread;
|
||||
|
||||
#[test]
|
||||
fn execute_mod() {
|
||||
|
@ -379,14 +378,16 @@ mod tests {
|
|||
let resource = worker.state.resource.clone();
|
||||
let rid = resource.rid;
|
||||
|
||||
tokio::spawn(lazy(move || {
|
||||
worker.then(move |r| -> Result<(), ()> {
|
||||
let worker_future = worker
|
||||
.then(move |r| -> Result<(), ()> {
|
||||
resource.close();
|
||||
println!("workers.rs after resource close");
|
||||
js_check(r);
|
||||
Ok(())
|
||||
})
|
||||
}));
|
||||
}).shared();
|
||||
|
||||
let worker_future_ = worker_future.clone();
|
||||
tokio::spawn(lazy(move || worker_future_.then(|_| Ok(()))));
|
||||
|
||||
assert_eq!(resources::get_type(rid), Some("worker".to_string()));
|
||||
|
||||
|
@ -395,9 +396,7 @@ mod tests {
|
|||
assert!(r.is_ok());
|
||||
debug!("rid {:?}", rid);
|
||||
|
||||
// TODO Need a way to get a future for when a resource closes.
|
||||
// For now, just sleep for a bit.
|
||||
thread::sleep(std::time::Duration::from_millis(1000));
|
||||
worker_future.wait().unwrap();
|
||||
assert_eq!(resources::get_type(rid), None);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue