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

doc-tests don't work with macros 1.1 #39064

Closed
colin-kiegel opened this issue Jan 14, 2017 · 5 comments
Closed

doc-tests don't work with macros 1.1 #39064

colin-kiegel opened this issue Jan 14, 2017 · 5 comments

Comments

@colin-kiegel
Copy link

It looks like having proc-macro = true in Cargo.toml disables all doc-tests. However unit tests #[test] work fine.

Steps to reproduce

  1. cargo new foo

  2. edit Cargo.toml

# ... the usual
[lib]
proc-macro = true
  1. edit src/lib.rs
//! ```rust
//! fn main() { panic!() } /* <-- this test should fail */
//! ```

#![crate_type = "proc-macro"]
extern crate proc_macro;

#[proc_macro_derive(Foo)]
pub fn derive(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
    unimplemented!()
}
  1. cargo test
running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
@colin-kiegel
Copy link
Author

just linking related tickets to attract some more attention :-)

@sanmai-NL
Copy link

@colin-kiegel: I think this should be filed at rust-lang/cargo, no?

@colin-kiegel
Copy link
Author

ok, I filed it there too: rust-lang/cargo#3545

I'm not sure if this ticket belongs here or with cargo, so I'll leave it to someone else to close one of these tickets.

@keeperofdakeys
Copy link
Contributor

I'll take a look at this, it's most likely a rust bug. There is probably a codepath that isn't visited because it's a proc macro crate.

@keeperofdakeys
Copy link
Contributor

From what I can see, this is both a rust bug and a cargo bug. On a proc macro crate, cargo doesn't call rustdoc --test, and rustdoc --test doesn't actually work on proc macro crates. Both should be simple to fix though.

bors added a commit that referenced this issue Jan 19, 2017
…hton

Stop warning when doc testing proc macro crates

Fixes #39064

Add the test option to the session struct that is passed
to phase_2_configure_and_expand function inside the
rustdoc test module.

This prevents the warning code from triggering when
parsing proc_macro_derive attributes, just like when
`--test` is normally invoked.

This change makes the warning disappear, but I'm not sure what else it might change. So this early PR is mainly to run the test suite, and to get feedback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants