From a4c92253a402f1a34cc2dba12de59e00417acb63 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Thu, 31 Oct 2024 23:27:32 +0100 Subject: [PATCH] Improved how references test handles paths --- crates/cli/tests/reference.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index df9c7d27399..76d9a4a9756 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -42,7 +42,7 @@ fn main() -> Result<()> { let filter = env::args().nth(1); let mut tests = Vec::new(); - let dir = env::current_dir()?.join("tests/reference"); + let dir = repo_root().join("crates/cli/tests/reference"); for entry in dir.read_dir()? { let path = entry?.path(); if path.extension().and_then(|s| s.to_str()) != Some("rs") { @@ -224,19 +224,15 @@ fn diff(a: &str, b: &str) -> Result<()> { } fn target_dir() -> PathBuf { - let mut dir = env::current_exe().unwrap(); - dir.pop(); // current exe - if dir.ends_with("deps") { - dir.pop(); - } - dir.pop(); // debug and/or release - dir + repo_root().join("target/tests/reference") } fn repo_root() -> PathBuf { let mut repo_root = env::current_dir().unwrap(); - repo_root.pop(); // remove 'cli' - repo_root.pop(); // remove 'crates' + if repo_root.file_name() == Some("cli".as_ref()) { + repo_root.pop(); // remove 'cli' + repo_root.pop(); // remove 'crates' + } repo_root }