-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage: Bless coverage attribute tests
- Loading branch information
Showing
10 changed files
with
648 additions
and
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,45 @@ | ||
#![feature(coverage_attribute)] | ||
//@ edition: 2021 | ||
|
||
// Tests the error messages produced (or not produced) by various unusual | ||
// uses of the `#[coverage(..)]` attribute. | ||
|
||
// FIXME(#126658): Multiple coverage attributes with the same value are useless, | ||
// and should probably produce a diagnostic. | ||
#[coverage(off)] | ||
#[coverage(off)] //~ ERROR multiple `coverage` attributes | ||
#[coverage(off)] | ||
fn multiple_consistent() {} | ||
|
||
// FIXME(#126658): When there are multiple inconsistent coverage attributes, | ||
// it's unclear which one will prevail. | ||
#[coverage(off)] | ||
#[coverage(off)] //~ ERROR multiple `coverage` attributes | ||
#[coverage(on)] | ||
fn multiple_inconsistent() {} | ||
|
||
#[coverage] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage] //~ ERROR malformed `coverage` attribute input | ||
fn bare_word() {} | ||
|
||
// FIXME(#126658): This shows as multiple different errors, one of which suggests | ||
// writing bare `#[coverage]`, which is not allowed. | ||
#[coverage = true] | ||
//~^ ERROR expected `coverage(off)` or `coverage(on)` | ||
//~| ERROR malformed `coverage` attribute input | ||
//~| HELP the following are the possible correct uses | ||
//~| SUGGESTION #[coverage(on|off)] | ||
#[coverage = true] //~ ERROR malformed `coverage` attribute input | ||
fn key_value() {} | ||
|
||
#[coverage()] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage()] //~ ERROR malformed `coverage` attribute input | ||
fn list_empty() {} | ||
|
||
#[coverage(off, off)] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(off, off)] //~ ERROR malformed `coverage` attribute input | ||
fn list_consistent() {} | ||
|
||
#[coverage(off, on)] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(off, on)] //~ ERROR malformed `coverage` attribute input | ||
fn list_inconsistent() {} | ||
|
||
#[coverage(bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(bogus)] //~ ERROR malformed `coverage` attribute input | ||
fn bogus_word() {} | ||
|
||
#[coverage(bogus, off)] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(bogus, off)] //~ ERROR malformed `coverage` attribute input | ||
fn bogus_word_before() {} | ||
|
||
#[coverage(off, bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(off, bogus)] //~ ERROR malformed `coverage` attribute input | ||
fn bogus_word_after() {} | ||
|
||
#[coverage(off,)] | ||
#[coverage(off,)] // (OK!) | ||
fn comma_after() {} | ||
|
||
// FIXME(#126658): This shows as multiple different errors. | ||
#[coverage(,off)] | ||
//~^ ERROR expected identifier, found `,` | ||
//~| HELP remove this comma | ||
//~| ERROR expected `coverage(off)` or `coverage(on)` | ||
#[coverage(,off)] //~ ERROR expected identifier, found `,` | ||
fn comma_before() {} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,78 +1,139 @@ | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:23:1 | ||
| | ||
LL | #[coverage = true] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(on|off)] | ||
--> $DIR/bad-syntax.rs:15:1 | ||
| | ||
LL | #[coverage] | ||
| ^^^^^^^^^^^ | ||
| | ||
|
||
error: expected identifier, found `,` | ||
--> $DIR/bad-syntax.rs:52:12 | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(,off)] | ||
| ^ | ||
| | | ||
| expected identifier | ||
| help: remove this comma | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:18:1 | ||
| | ||
LL | #[coverage] | ||
| ^^^^^^^^^^^ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:23:1 | ||
| | ||
LL | #[coverage = true] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:30:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:21:1 | ||
| | ||
LL | #[coverage()] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:33:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:24:1 | ||
| | ||
LL | #[coverage(off, off)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:36:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:27:1 | ||
| | ||
LL | #[coverage(off, on)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:39:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:30:1 | ||
| | ||
LL | #[coverage(bogus)] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:42:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:33:1 | ||
| | ||
LL | #[coverage(bogus, off)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:45:1 | ||
error: malformed `coverage` attribute input | ||
--> $DIR/bad-syntax.rs:36:1 | ||
| | ||
LL | #[coverage(off, bogus)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL | #[coverage(off)] | ||
| ~~~~~~~~~~~~~~~~ | ||
LL | #[coverage(on)] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: expected `coverage(off)` or `coverage(on)` | ||
--> $DIR/bad-syntax.rs:52:1 | ||
error: expected identifier, found `,` | ||
--> $DIR/bad-syntax.rs:42:12 | ||
| | ||
LL | #[coverage(,off)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| ^ | ||
| | | ||
| expected identifier | ||
| help: remove this comma | ||
|
||
error: multiple `coverage` attributes | ||
--> $DIR/bad-syntax.rs:7:1 | ||
| | ||
LL | #[coverage(off)] | ||
| ^^^^^^^^^^^^^^^^ help: remove this attribute | ||
| | ||
note: attribute also specified here | ||
--> $DIR/bad-syntax.rs:8:1 | ||
| | ||
LL | #[coverage(off)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: multiple `coverage` attributes | ||
--> $DIR/bad-syntax.rs:11:1 | ||
| | ||
LL | #[coverage(off)] | ||
| ^^^^^^^^^^^^^^^^ help: remove this attribute | ||
| | ||
note: attribute also specified here | ||
--> $DIR/bad-syntax.rs:12:1 | ||
| | ||
LL | #[coverage(on)] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 11 previous errors | ||
|
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
Oops, something went wrong.