Skip to content

Commit 459d677

Browse files
Add test for rustdoc cfg(test) feature
1 parent 8ed2292 commit 459d677

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/test/rustdoc-ui/cfg-test.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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;

src/test/rustdoc-ui/cfg-test.stdout

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+

0 commit comments

Comments
 (0)