forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59940 - GuillaumeGomez:rustdoc-test, r=ollie27
Set cfg(test) when rustdoc is running with --test option Following a [discussion on twitter](https://twitter.com/burntsushi5/status/1117091914199785473), I proposed this change. What do you think about it? r? @QuietMisdreavus cc @BurntSushi
- Loading branch information
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// compile-pass | ||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
|
||
/// this doctest will be ignored: | ||
/// | ||
/// ``` | ||
/// assert!(false); | ||
/// ``` | ||
#[cfg(not(test))] | ||
pub struct Foo; | ||
|
||
/// this doctest will be tested: | ||
/// | ||
/// ``` | ||
/// assert!(true); | ||
/// ``` | ||
#[cfg(test)] | ||
pub struct Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
running 1 test | ||
test $DIR/cfg-test.rs - Foo (line 15) ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out | ||
|