1 // check-pass 2 // compile-flags:--test --test-args --test-threads=1 3 // normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" 4 // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" 5 6 // Crates like core have doctests gated on `cfg(not(test))` so we need to make 7 // sure `cfg(test)` is not active when running `rustdoc --test`. 8 9 /// this doctest will be ignored: 10 /// 11 /// ``` 12 /// assert!(false); 13 /// ``` 14 #[cfg(test)] 15 pub struct Foo; 16 17 /// this doctest will be tested: 18 /// 19 /// ``` 20 /// assert!(true); 21 /// ``` 22 #[cfg(not(test))] 23 pub struct Foo; 24 25 /// this doctest will be tested, but will not appear in documentation: 26 /// 27 /// ``` 28 /// assert!(true) 29 /// ``` 30 #[cfg(doctest)] 31 pub struct Bar; 32