Skip to content
Permalink
Browse files

better wait for removed_from_resource_table_on_close test (denoland#2104

)
  • Loading branch information...
afinch7 authored and ry committed Apr 12, 2019
1 parent e0edcc9 commit d3bd5879c3b1a26cc09a5374bf2b5ee63071fe29
Showing with 7 additions and 8 deletions.
  1. +7 −8 cli/worker.rs
@@ -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);
})
}

0 comments on commit d3bd587

Please sign in to comment.
You can’t perform that action at this time.