aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libanalysis/tests/tests.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs
index 9d2db731b..1f210f579 100644
--- a/crates/libanalysis/tests/tests.rs
+++ b/crates/libanalysis/tests/tests.rs
@@ -7,7 +7,7 @@ use std::{
7 path::{Path}, 7 path::{Path},
8}; 8};
9 9
10use relative_path::RelativePath; 10use relative_path::{RelativePath, RelativePathBuf};
11use libanalysis::{AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId}; 11use libanalysis::{AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId};
12use test_utils::assert_eq_dbg; 12use test_utils::assert_eq_dbg;
13 13
@@ -28,18 +28,15 @@ impl FileResolver for FileMap {
28 self.path(id).file_stem().unwrap().to_str().unwrap().to_string() 28 self.path(id).file_stem().unwrap().to_str().unwrap().to_string()
29 } 29 }
30 fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> { 30 fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> {
31 let path = { 31 let path = rel.to_path(self.path(id));
32 if rel.starts_with("..") { 32 let path = path.strip_prefix("/").unwrap();
33 rel.strip_prefix("..").unwrap() 33 let path = RelativePathBuf::from_path(&path).unwrap().normalize();
34 .to_path(&self.path(id).parent().unwrap())
35 } else {
36 rel.to_path(self.path(id))
37 }
38 };
39 let path = &path.to_str().unwrap()[1..];
40 let path = RelativePath::new(&path[0..]).normalize();
41 let &(id, _) = self.0.iter() 34 let &(id, _) = self.0.iter()
42 .find(|it| path == RelativePath::new(&it.1[0..]).normalize())?; 35 .find(|it| {
36 let p = Path::new(it.1).strip_prefix("/").unwrap();
37 let p = RelativePathBuf::from_path(p).unwrap();
38 path == p
39 })?;
43 Some(FileId(id)) 40 Some(FileId(id))
44 } 41 }
45} 42}