Update rustdoc coverage UI test

This commit is contained in:
Guillaume Gomez 2020-08-19 22:44:58 +02:00
parent 3307ba8212
commit 6fb7e02a36
3 changed files with 51 additions and 7 deletions

View File

@ -249,7 +249,12 @@ impl fold::DocFolder for CoverageCalculator {
);
if should_have_doc_examples {
find_testable_code(
&i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::<Vec<_>>().join("\n"),
&i.attrs
.doc_strings
.iter()
.map(|d| d.as_str())
.collect::<Vec<_>>()
.join("\n"),
&mut tests,
ErrorCodes::No,
false,
@ -259,10 +264,11 @@ impl fold::DocFolder for CoverageCalculator {
let has_doc_example = tests.found_tests != 0;
debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);
self.items
.entry(i.source.filename.clone())
.or_default()
.count_item(has_docs, has_doc_example, should_have_doc_examples);
self.items.entry(i.source.filename.clone()).or_default().count_item(
has_docs,
has_doc_example,
should_have_doc_examples,
);
}
}

View File

@ -12,16 +12,54 @@ pub mod foo {
pub struct X;
/// Bar
///
/// ```
/// let x = 12;
/// ```
pub mod bar {
/// bar
pub struct Bar;
/// X
pub enum X { Y }
pub enum X {
/// ```
/// let x = "should be ignored!";
/// ```
Y
}
}
/// yolo
///
/// ```text
/// should not be counted as a code example!
/// ```
pub enum Yolo { X }
impl Yolo {
/// ```
/// let x = "should be ignored!";
/// ```
pub const Const: u32 = 0;
}
pub struct Xo<T: Clone> {
/// ```
/// let x = "should be ignored!";
/// ```
x: T,
}
/// ```
/// let x = "should be ignored!";
/// ```
pub static StaticFoo: u32 = 0;
/// ```
/// let x = "should be ignored!";
/// ```
pub const ConstFoo: u32 = 0;
/// ```
/// let x = "should be ignored!";
/// ```
pub type TypeFoo = u32;

View File

@ -1 +1 @@
{"$DIR/json.rs":{"total":13,"with_docs":7,"with_examples":0}}
{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":10,"with_examples":1}}