From 774411c63674c4b4cc439a409e3e6b880997b065 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Wed, 24 Feb 2016 20:26:49 -0800 Subject: [PATCH] Create temp file using tempdir in test --- tarpc/Cargo.toml | 1 + tarpc/src/macros.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index 510f62d..5b65672 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -20,3 +20,4 @@ unix_socket = "^0.5.0" [dev-dependencies] lazy_static = "^0.1.15" env_logger = "^0.3.2" +tempdir = "^0.3.4" diff --git a/tarpc/src/macros.rs b/tarpc/src/macros.rs index 1c31d07..11a9b45 100644 --- a/tarpc/src/macros.rs +++ b/tarpc/src/macros.rs @@ -522,6 +522,7 @@ mod syntax_test { #[cfg(test)] mod functional_test { extern crate env_logger; + extern crate tempdir; use Config; use transport::unix::UnixTransport; @@ -583,16 +584,15 @@ mod functional_test { #[test] fn async_try_clone_unix() { - let handle = Server.spawn_with_config(UnixTransport("/tmp/test"), + let temp_dir = tempdir::TempDir::new(module_path!()).unwrap(); + let temp_file = temp_dir.path().join("async_try_clone_unix.tmp"); + let handle = Server.spawn_with_config(UnixTransport(temp_file), Config::default()).unwrap(); let client1 = AsyncClient::with_config(handle.dialer(), Config::default()).unwrap(); let client2 = client1.try_clone().unwrap(); assert_eq!(3, client1.add(1, 2).get().unwrap()); assert_eq!(3, client2.add(1, 2).get().unwrap()); - drop(client1); - drop(client2); - handle.shutdown(); } // Tests that a server can be wrapped in an Arc; no need to run, just compile