From 94229f71fef7860835d36e88070b2ea428aa49c5 Mon Sep 17 00:00:00 2001 From: michele Date: Sun, 19 Jun 2022 20:59:40 +0200 Subject: [PATCH] #148 Little refactor to support a more elastic local dependency --- rstest_test/src/prj.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rstest_test/src/prj.rs b/rstest_test/src/prj.rs index 9ba29e9..a36de9f 100644 --- a/rstest_test/src/prj.rs +++ b/rstest_test/src/prj.rs @@ -186,10 +186,19 @@ impl Project { pub fn add_local_dependency(&self, name: &str) { self.add_dependency( name, - format!(r#"{{path="{}"}}"#, self.current_dir_str()).as_str(), + format!(r#"{{path="{}"}}"#, self.exec_dir_str()).as_str(), ); } + pub fn exec_dir_str(&self) -> String { + std::env::current_dir() + .unwrap() + .as_os_str() + .to_str() + .unwrap() + .to_owned() + } + fn workspace_add(&self, prj: &str) { let mut doc = self.read_cargo_toml(); @@ -230,15 +239,6 @@ impl Project { .expect("cannot write Cargo.toml"); } - fn current_dir_str(&self) -> String { - std::env::current_dir() - .unwrap() - .as_os_str() - .to_str() - .unwrap() - .to_owned() - } - fn cargo_channel_arg(&self) -> String { match &self.channel { Channel::Stable => "+stable".into(),