File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,9 @@ impl Options {
351351 . unwrap_or_else ( || PathBuf :: from ( "doc" ) ) ;
352352 let mut cfgs = matches. opt_strs ( "cfg" ) ;
353353 cfgs. push ( "rustdoc" . to_string ( ) ) ;
354+ if should_test {
355+ cfgs. push ( "test" . to_string ( ) ) ;
356+ }
354357
355358 let extension_css = matches. opt_str ( "e" ) . map ( |s| PathBuf :: from ( & s) ) ;
356359
Original file line number Diff line number Diff line change 1+ // compile-pass
2+ // compile-flags:--test
3+ // normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
4+
5+ /// this doctest will be ignored:
6+ ///
7+ /// ```
8+ /// assert!(false);
9+ /// ```
10+ #[ cfg( not( test) ) ]
11+ pub struct Foo ;
12+
13+ /// this doctest will be tested:
14+ ///
15+ /// ```
16+ /// assert!(true);
17+ /// ```
18+ #[ cfg( test) ]
19+ pub struct Foo ;
Original file line number Diff line number Diff line change 1+
2+ running 1 test
3+ test $DIR/cfg-test.rs - Foo (line 15) ... ok
4+
5+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
6+
You can’t perform that action at this time.
0 commit comments