diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-05 16:28:21 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-05 16:28:21 +0100 |
commit | 8f30179f8256142651f8e65405dc4541391405ed (patch) | |
tree | 09abb27e1ec29d39bc04e188bd913cec56af34ac /crates/libanalysis/tests | |
parent | ad451686a807cf5f86826c80ad22c04c559a8589 (diff) | |
parent | d0e22d7578bc789748b784bd72f338908e10d611 (diff) |
Merge #57
57: less hacky paths r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/libanalysis/tests')
-rw-r--r-- | crates/libanalysis/tests/tests.rs | 21 |
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 | ||
10 | use relative_path::RelativePath; | 10 | use relative_path::{RelativePath, RelativePathBuf}; |
11 | use libanalysis::{AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId}; | 11 | use libanalysis::{AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId}; |
12 | use test_utils::assert_eq_dbg; | 12 | use 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 | } |