diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-02-15 22:47:11 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-02-16 22:35:29 +0100 |
| commit | 047a215b4d9cf762d3704ee02b76467897bbbe21 (patch) | |
| tree | 131d5db6ff085bede8cdbf7db21f37ecfc05e849 /src | |
| parent | 62eb6056d332be09206dc664f2e949ae64341e64 (diff) | |
| download | rust-047a215b4d9cf762d3704ee02b76467897bbbe21.tar.gz rust-047a215b4d9cf762d3704ee02b76467897bbbe21.zip | |
Set rustdoc --test files' path relative to the current directory
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/test.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 1c37067d7f6..c7000ee1e40 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -12,7 +12,7 @@ use std::env; use std::ffi::OsString; use std::io::prelude::*; use std::io; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::panic::{self, AssertUnwindSafe}; use std::process::Command; use std::rc::Rc; @@ -485,7 +485,15 @@ impl Collector { pub fn get_filename(&self) -> String { if let Some(ref codemap) = self.codemap { - codemap.span_to_filename(self.position) + let filename = codemap.span_to_filename(self.position); + if let Ok(cur_dir) = env::current_dir() { + if let Ok(path) = Path::new(&filename).strip_prefix(&cur_dir) { + if let Some(path) = path.to_str() { + return path.to_owned(); + } + } + } + filename } else if let Some(ref filename) = self.filename { filename.clone() } else { |
