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

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

Closed
elichai opened this issue May 1, 2019 · 3 comments
Closed

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

elichai opened this issue May 1, 2019 · 3 comments
Labels
C-bug Category: bug

Comments

@elichai
Copy link

elichai commented May 1, 2019

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)`
@elichai elichai added the C-bug Category: bug label May 1, 2019
@ehuss
Copy link
Contributor

ehuss commented May 1, 2019

This just changed a few days ago (rust-lang/rust#59940). Can you try with the latest nightly and see if it behaves the way you want?

@elichai
Copy link
Author

elichai commented May 1, 2019

@ehuss Wow!, yes it seems that latest nightly solves this.
I'm sorry I missed it before.

(FYI Idk how the C-bug got there)

Thank you!

@elichai elichai closed this as completed May 1, 2019
@ehuss
Copy link
Contributor

ehuss commented May 1, 2019

Sure, no problem. The C-bug label is added by GitHub automatically based on which template you pick. I'll close this for now since it seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants