fix tests on windows

This commit is contained in:
Aleksey Kladov 2018-09-05 15:03:27 +01:00
parent f87771092c
commit 649f7faf7d

View File

@ -28,11 +28,18 @@ impl FileResolver for FileMap {
self.path(id).file_stem().unwrap().to_str().unwrap().to_string()
}
fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> {
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))
}
}