Skip to content

Commit

Permalink
Rollup merge of rust-lang#39859 - GuillaumeGomez:rustdoc-test-relativ…
Browse files Browse the repository at this point in the history
…e-path, r=alexcrichton

Set rustdoc --test files' path relative to the current directory

r? @alexcrichton
  • Loading branch information
frewsxcv authored Feb 17, 2017
2 parents 5430487 + 047a215 commit f3d4c8c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f3d4c8c

Please sign in to comment.