Skip to content

Commit

Permalink
Rollup merge of rust-lang#72180 - euclio:rustdoc-test-extra-space, r=…
Browse files Browse the repository at this point in the history
…Dylan-DPC

remove extra space from crate-level doctest names

Before:

```
running 2 tests
test src/test/rustdoc-ui/doctest-output.rs - foo::bar (line 11) ... ok
test src/test/rustdoc-ui/doctest-output.rs -  (line 5) ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```

After:

```
running 2 tests
test src/test/rustdoc-ui/doctest-output.rs - foo::bar (line 11) ... ok
test src/test/rustdoc-ui/doctest-output.rs - (line 5) ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```
  • Loading branch information
Dylan-DPC authored May 15, 2020
2 parents 6f0b2b7 + ce915f5 commit 471d6d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,11 @@ impl Collector {
}

fn generate_name(&self, line: usize, filename: &FileName) -> String {
format!("{} - {} (line {})", filename, self.names.join("::"), line)
let mut item_path = self.names.join("::");
if !item_path.is_empty() {
item_path.push(' ');
}
format!("{} - {}(line {})", filename, item_path, line)
}

pub fn set_position(&mut self, position: Span) {
Expand Down
15 changes: 15 additions & 0 deletions src/test/rustdoc-ui/doctest-output.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
// check-pass

//! ```
//! assert_eq!(1 + 1, 2);
//! ```
pub mod foo {

/// ```
/// assert_eq!(1 + 1, 2);
/// ```
pub fn bar() {}
}
7 changes: 7 additions & 0 deletions src/test/rustdoc-ui/doctest-output.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

running 2 tests
test $DIR/doctest-output.rs - (line 5) ... ok
test $DIR/doctest-output.rs - foo::bar (line 11) ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

0 comments on commit 471d6d3

Please sign in to comment.