diff --git a/tests/test-framework/src/fetch.rs b/tests/test-framework/src/fetch.rs index c2357e71e9..f1e1b1a868 100644 --- a/tests/test-framework/src/fetch.rs +++ b/tests/test-framework/src/fetch.rs @@ -21,7 +21,7 @@ use std::{ use walkdir::WalkDir; -pub fn find_tests(path: &'_ Path) -> impl Iterator + '_ { +pub fn find_tests(path: &Path) -> impl Iterator { WalkDir::new(path).into_iter().flatten().filter_map(move |f| { let path = f.path(); path.extension().filter(|s| *s == "leo").map(|_| { diff --git a/tests/test-framework/src/runner.rs b/tests/test-framework/src/runner.rs index 6a0bf15972..48388e7f58 100644 --- a/tests/test-framework/src/runner.rs +++ b/tests/test-framework/src/runner.rs @@ -161,20 +161,14 @@ impl TestCases { } fn clear_expectations(&self, path: &Path, expectation_category: &str) -> (PathBuf, Option) { - let path = Path::new(&path); - let relative_path = path.strip_prefix(&self.path_prefix).expect("path error for test"); - let expectation_dir = self.path_prefix.clone(); - let mut expectation_path = expectation_dir; - expectation_path.push(expectation_category); - expectation_path.push(relative_path.parent().expect("no parent dir for test")); - let mut expectation_name = relative_path - .file_name() - .expect("no file name for test") - .to_str() - .unwrap() - .to_string(); - expectation_name += ".out"; - expectation_path.push(&expectation_name); + let test_dir = [env!("CARGO_MANIFEST_DIR"), "../../tests/"].iter().collect::(); + let relative_path = path.strip_prefix(&test_dir).expect("path error for test"); + let expectation_path = test_dir + .join("expectations") + .join(expectation_category) + .join(relative_path.parent().expect("no parent dir for test")) + .join(relative_path.file_name().expect("no file name for test")) + .with_extension("out"); if expectation_path.exists() { if !is_env_var_set("CLEAR_LEO_TEST_EXPECTATIONS") {