From: Josh Date: Tue, 17 Jan 2017 23:48:35 +0000 (+1100) Subject: Add tests for doc testing proc macro crates X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~11^2~31^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b3b8b7e007a8b1b8e58518018d1644c700621117;p=cargo.git Add tests for doc testing proc macro crates --- diff --git a/tests/proc-macro.rs b/tests/proc-macro.rs index 59dc96e21..dda231581 100644 --- a/tests/proc-macro.rs +++ b/tests/proc-macro.rs @@ -178,3 +178,57 @@ fn plugin_and_proc_macro() { assert_that(questionable.cargo_process("build"), execs().with_status(101).with_stderr_contains(msg)); } + +#[test] +fn proc_macro_doctest() { + if !is_nightly() { + return + } + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + [lib] + proc-macro = true + "#) + .file("src/lib.rs", r#" +#![feature(proc_macro, proc_macro_lib)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +/// ``` +/// assert!(true); +/// ``` +#[proc_macro_derive(Bar)] +pub fn derive(_input: TokenStream) -> TokenStream { + "".parse().unwrap() +} + +#[test] +fn a() { + assert!(true); +} +"#); + foo.build(); + + assert_that(foo.cargo_process("test"), + execs().with_status(0) + .with_stdout_contains("\ +running 1 test +test a ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +").with_stdout_contains("\ +running 1 test +test derive_0 ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +")); +}