send a reply when thread is done exiting

fixed failing tests

fix tests

handle error instead of just unwrappng it

create a channel per thread and update tests with a call to rx.recv().unwrap()
This commit is contained in:
Abelardo E. Mendoza 2016-05-29 13:00:09 -06:00
parent e8e7c6545d
commit 88980dc7a5
6 changed files with 33 additions and 11 deletions

View file

@ -39,13 +39,16 @@ impl LoadOrigin for ResourceTest {
#[test]
fn test_exit() {
let (tx, _rx) = ipc::channel().unwrap();
let (sender, receiver) = ipc::channel().unwrap();
let resource_thread = new_core_resource_thread("".to_owned(), None, ProfilerChan(tx));
resource_thread.send(CoreResourceMsg::Exit).unwrap();
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
receiver.recv().unwrap();
}
#[test]
fn test_bad_scheme() {
let (tx, _rx) = ipc::channel().unwrap();
let (sender, receiver) = ipc::channel().unwrap();
let resource_thread = new_core_resource_thread("".to_owned(), None, ProfilerChan(tx));
let (start_chan, start) = ipc::channel().unwrap();
let url = Url::parse("bogus://whatever").unwrap();
@ -57,7 +60,8 @@ fn test_bad_scheme() {
ProgressMsg::Done(result) => { assert!(result.is_err()) }
_ => panic!("bleh")
}
resource_thread.send(CoreResourceMsg::Exit).unwrap();
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
receiver.recv().unwrap();
}
#[test]
@ -223,6 +227,7 @@ fn test_cancelled_listener() {
});
let (tx, _rx) = ipc::channel().unwrap();
let (exit_sender, exit_receiver) = ipc::channel().unwrap();
let resource_thread = new_core_resource_thread("".to_owned(), None, ProfilerChan(tx));
let (sender, receiver) = ipc::channel().unwrap();
let (id_sender, id_receiver) = ipc::channel().unwrap();
@ -244,5 +249,6 @@ fn test_cancelled_listener() {
let response = receiver.recv().unwrap();
assert_eq!(response.progress_port.recv().unwrap(),
ProgressMsg::Done(Err(NetworkError::LoadCancelled)));
resource_thread.send(CoreResourceMsg::Exit).unwrap();
resource_thread.send(CoreResourceMsg::Exit(exit_sender)).unwrap();
exit_receiver.recv().unwrap();
}