Skip to content

Update ignore to use the attribute template #1881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions src/attributes/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,49 @@ r[attributes.testing.ignore]
## The `ignore` attribute

r[attributes.testing.ignore.intro]
A function annotated with the `test` attribute can also be annotated with the
`ignore` attribute. The *`ignore` attribute* tells the test harness to not
execute that function as a test. It will still be compiled when in test mode.
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.

> [!EXAMPLE]
> ```rust
> #[test]
> #[ignore]
> fn check_thing() {
> // …
> }
> ```

> [!NOTE]
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.

r[attributes.testing.ignore.syntax]
The `ignore` attribute may optionally be written with the [MetaNameValueStr]
syntax to specify a reason why the test is ignored.
The `ignore` attribute uses either the [MetaWord] or [MetaNameValueStr] syntax.

```rust
#[test]
#[ignore = "not yet implemented"]
fn mytest() {
// …
}
```
r[attributes.testing.ignore.reason]
The [MetaNameValueStr] form of the `ignore` attribute provides a way to specify a reason why the test is ignored.

> [!EXAMPLE]
> ```rust
> #[test]
> #[ignore = "not yet implemented"]
> fn mytest() {
> // …
> }
> ```

r[attributes.testing.ignore.allowed-positions]
The `ignore` attribute may be applied to functions annotated with the `test` attribute.

> [!NOTE]
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
> `rustc` currently warns when `ignore` is used in some other situations. This may become an error in the future.

r[attributes.testing.ignore.duplicates]
Only the first instance of `ignore` on a function is honored.

> [!NOTE]
> `rustc` currently ignores duplicate `ignore` attributes. This may become an error in the future.

r[attributes.testing.ignore.behavior]
Ignored tests are still compiled when in test mode, but they are not executed.

r[attributes.testing.should_panic]
## The `should_panic` attribute
Expand Down