Skip to content

Commit f1b060c

Browse files
authored
Merge pull request #1881 from ehuss/ignore
Update `ignore` to use the attribute template
2 parents cdb998b + 8cb85a5 commit f1b060c

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/attributes/testing.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,49 @@ r[attributes.testing.ignore]
7676
## The `ignore` attribute
7777
7878
r[attributes.testing.ignore.intro]
79-
A function annotated with the `test` attribute can also be annotated with the
80-
`ignore` attribute. The *`ignore` attribute* tells the test harness to not
81-
execute that function as a test. It will still be compiled when in test mode.
79+
The *`ignore` [attribute][attributes]* can be used with the [`test` attribute][attributes.testing.test] to tell the test harness to not execute that function as a test.
80+
81+
> [!EXAMPLE]
82+
> ```rust
83+
> #[test]
84+
> #[ignore]
85+
> fn check_thing() {
86+
> //
87+
> }
88+
> ```
89+
90+
> [!NOTE]
91+
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
8292
8393
r[attributes.testing.ignore.syntax]
84-
The `ignore` attribute may optionally be written with the [MetaNameValueStr]
85-
syntax to specify a reason why the test is ignored.
94+
The `ignore` attribute uses either the [MetaWord] or [MetaNameValueStr] syntax.
8695
87-
```rust
88-
#[test]
89-
#[ignore = "not yet implemented"]
90-
fn mytest() {
91-
//
92-
}
93-
```
96+
r[attributes.testing.ignore.reason]
97+
The [MetaNameValueStr] form of the `ignore` attribute provides a way to specify a reason why the test is ignored.
98+
99+
> [!EXAMPLE]
100+
> ```rust
101+
> #[test]
102+
> #[ignore = "not yet implemented"]
103+
> fn mytest() {
104+
> //
105+
> }
106+
> ```
107+
108+
r[attributes.testing.ignore.allowed-positions]
109+
The `ignore` attribute may be applied to functions annotated with the `test` attribute.
94110
95111
> [!NOTE]
96-
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
112+
> `rustc` currently warns when `ignore` is used in some other situations. This may become an error in the future.
113+
114+
r[attributes.testing.ignore.duplicates]
115+
Only the first instance of `ignore` on a function is honored.
116+
117+
> [!NOTE]
118+
> `rustc` currently ignores duplicate `ignore` attributes. This may become an error in the future.
119+
120+
r[attributes.testing.ignore.behavior]
121+
Ignored tests are still compiled when in test mode, but they are not executed.
97122
98123
r[attributes.testing.should_panic]
99124
## The `should_panic` attribute

0 commit comments

Comments
 (0)