From 649f7faf7d6eb25635dd624a2ea50a47ac090e09 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Sep 2018 15:03:27 +0100 Subject: [PATCH] fix tests on windows --- crates/libanalysis/tests/tests.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs index 4fae7c31376..9d2db731bdc 100644 --- a/crates/libanalysis/tests/tests.rs +++ b/crates/libanalysis/tests/tests.rs @@ -28,11 +28,18 @@ fn file_stem(&self, id: FileId) -> String { self.path(id).file_stem().unwrap().to_str().unwrap().to_string() } fn resolve(&self, id: FileId, rel: &RelativePath) -> Option { - let path = rel.to_path(self.path(id)); - let path = path.to_str().unwrap(); - let path = RelativePath::new(&path[1..]).normalize(); + let path = { + if rel.starts_with("..") { + rel.strip_prefix("..").unwrap() + .to_path(&self.path(id).parent().unwrap()) + } else { + rel.to_path(self.path(id)) + } + }; + let path = &path.to_str().unwrap()[1..]; + let path = RelativePath::new(&path[0..]).normalize(); let &(id, _) = self.0.iter() - .find(|it| path == RelativePath::new(&it.1[1..]).normalize())?; + .find(|it| path == RelativePath::new(&it.1[0..]).normalize())?; Some(FileId(id)) } }