Skip to content

Documentation tests don't move via #[cfg(test)] #6895

Closed

Description

Problem
Running cargo test doesn't do doc testing for documentation under #[cfg(test)]
Steps

///```rust
/// println!("test")
/// ```
extern "C" {}

#[cfg(test)]
mod A {
    ///```rust
    /// println!("test"
    /// ```
    extern "C" {}

    #[test]
    fn test() {
        println!("test")
    }
}

Output from cargo test:

running 1 test
test A::test ... ok

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

     Running target/debug/deps/test_cargo-81aed86b67506427

running 0 tests

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

   Doc-tests test-cargo

running 1 test
test src/lib.rs -  (line 3) ... ok

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

``

As you can see the first doc test is ran, the test in `A` also runs but the doc tests in `A` doesn't run

**Notes**

Output of `cargo version`:
`cargo 1.34.0 (6789d8a0a 2019-04-01)`
`rustc 1.34.1 (fc50f328b 2019-04-24)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions