From 4a35a86cbc730ee6bbc49a2f97db928b34f1ccce Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sun, 17 Jan 2016 21:56:30 -0800 Subject: [PATCH] Rename client_stubs => client_methods. Modify unit test to check for the Error variant returned on shutdown. --- tarpc/src/macros.rs | 4 ++-- tarpc/src/protocol.rs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tarpc/src/macros.rs b/tarpc/src/macros.rs index 42f8191..57eb1e8 100644 --- a/tarpc/src/macros.rs +++ b/tarpc/src/macros.rs @@ -4,7 +4,7 @@ macro_rules! as_item { ($i:item) => {$i} } // Required because if-let can't be used with irrefutable patterns, so it needs // to be special cased. #[macro_export] -macro_rules! client_stubs { +macro_rules! client_methods { ( { $(#[$attr:meta])* } $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty @@ -140,7 +140,7 @@ macro_rules! rpc { Ok(Client(inner)) } - client_stubs!( + client_methods!( $( { $(#[$attr])* } $fn_name($($arg: $in_),*) -> $out diff --git a/tarpc/src/protocol.rs b/tarpc/src/protocol.rs index 8143be2..3ba2397 100644 --- a/tarpc/src/protocol.rs +++ b/tarpc/src/protocol.rs @@ -561,7 +561,14 @@ mod test { let addr = serve_handle.local_addr().clone(); let client: Arc> = Arc::new(Client::new(addr, None).unwrap()); serve_handle.shutdown(); - let _ = client.rpc(&Request::Increment); // First failure will trigger reader to shutdown + match client.rpc(&Request::Increment) { + ok @ Ok(_) => panic!("Expected Err, got {:?}", ok), + Err(e) => if let super::Error::ConnectionBroken = e { + /* success */ + } else { + panic!("Expected Error::ConnectionBroken, got {:?}", e); + }, + } let _ = client.rpc(&Request::Increment); // Test whether second failure hangs }