Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] properly run doctests in standalone markdown files with pulldown #48410

Merged
merged 1 commit into from
Mar 3, 2018
Merged
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
13 changes: 3 additions & 10 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ fn partition_source(s: &str) -> (String, String) {
pub struct Collector {
pub tests: Vec<testing::TestDescAndFn>,
// to be removed when hoedown will be definitely gone
pub old_tests: HashMap<String, Vec<String>>,
pub old_tests: HashMap<FileName, Vec<String>>,

// The name of the test displayed to the user, separated by `::`.
//
Expand Down Expand Up @@ -501,14 +501,8 @@ impl Collector {
format!("{} - {} (line {})", filename, self.names.join("::"), line)
}

// to be removed once hoedown is gone
fn generate_name_beginning(&self, filename: &FileName) -> String {
format!("{} - {} (line", filename, self.names.join("::"))
}

pub fn add_old_test(&mut self, test: String, filename: FileName) {
let name_beg = self.generate_name_beginning(&filename);
let entry = self.old_tests.entry(name_beg)
let entry = self.old_tests.entry(filename.clone())
.or_insert(Vec::new());
entry.push(test.trim().to_owned());
}
Expand All @@ -520,10 +514,9 @@ impl Collector {
let name = self.generate_name(line, &filename);
// to be removed when hoedown is removed
if self.render_type == RenderType::Pulldown {
let name_beg = self.generate_name_beginning(&filename);
let mut found = false;
let test = test.trim().to_owned();
if let Some(entry) = self.old_tests.get_mut(&name_beg) {
if let Some(entry) = self.old_tests.get_mut(&filename) {
found = entry.remove_item(&test).is_some();
}
if !found {
Expand Down