Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ pub fn test(input: &str, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
let mut opts = TestOptions::default();
opts.no_crate_inject = true;
let mut collector = Collector::new(input.to_string(), cfgs, libs, externs,
true, opts, maybe_sysroot, None);
true, opts, maybe_sysroot, None,
Some(input.to_owned()));
find_testable_code(&input_str, &mut collector, DUMMY_SP);
test_args.insert(0, "rustdoctest".to_string());
testing::test_main(&test_args, collector.tests);
Expand Down
9 changes: 7 additions & 2 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ pub fn run(input: &str,
false,
opts,
maybe_sysroot,
Some(codemap));
Some(codemap),
None);

{
let dep_graph = DepGraph::new(false);
Expand Down Expand Up @@ -391,12 +392,13 @@ pub struct Collector {
maybe_sysroot: Option<PathBuf>,
position: Span,
codemap: Option<Rc<CodeMap>>,
filename: Option<String>,
}

impl Collector {
pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
use_headers: bool, opts: TestOptions, maybe_sysroot: Option<PathBuf>,
codemap: Option<Rc<CodeMap>>) -> Collector {
codemap: Option<Rc<CodeMap>>, filename: Option<String>) -> Collector {
Collector {
tests: Vec::new(),
names: Vec::new(),
Expand All @@ -411,6 +413,7 @@ impl Collector {
maybe_sysroot: maybe_sysroot,
position: DUMMY_SP,
codemap: codemap,
filename: filename,
}
}

Expand Down Expand Up @@ -483,6 +486,8 @@ impl Collector {
pub fn get_filename(&self) -> String {
if let Some(ref codemap) = self.codemap {
codemap.span_to_filename(self.position)
} else if let Some(ref filename) = self.filename {
filename.clone()
} else {
"<input>".to_owned()
}
Expand Down