Skip to content

Commit

Permalink
Adapt check-cfg tests to the new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed May 5, 2023
1 parent e512409 commit 6846f33
Show file tree
Hide file tree
Showing 47 changed files with 588 additions and 101 deletions.
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/check-cfg/check-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

/// uniz is nor a builtin nor pass as arguments so is unexpected
#[cfg(uniz)]
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/check-cfg-test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options
// compile-flags: --test --nocapture --check-cfg=configure(feature,"test") -Z unstable-options
// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-at-crate-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that #![allow(unexpected_cfgs)] works with --cfg
//
// check-pass
// compile-flags: --cfg=unexpected --check-cfg=names() -Z unstable-options
// compile-flags: --cfg=unexpected --check-cfg=exhaustive(names) -Z unstable-options

#![allow(unexpected_cfgs)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-macro-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that local #[allow(unexpected_cfgs)] works
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#[allow(unexpected_cfgs)]
fn foo() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-same-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#[allow(unexpected_cfgs)]
#[cfg(FALSE)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-top-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that a top-level #![allow(unexpected_cfgs)] works
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#![allow(unexpected_cfgs)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-upper-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that #[allow(unexpected_cfgs)] work if put on an upper level
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#[allow(unexpected_cfgs)]
mod aa {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/compact-names.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that we correctly emit an warning for compact cfg
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#![feature(cfg_target_compact)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/compact-values.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that we correctly emit an warning for compact cfg
//
// check-pass
// compile-flags:--check-cfg=values() -Z unstable-options
// compile-flags: --check-cfg=exhaustive(values) -Z unstable-options

#![feature(cfg_target_compact)]

Expand Down
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/concat-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// check-pass
// compile-flags: -Z unstable-options
// compile-flags: --check-cfg=configure(my_cfg,"foo") --check-cfg=configure(my_cfg,"bar")

#[cfg(my_cfg)]
//~^ WARNING unexpected `cfg` condition value
fn my_cfg() {}

#[cfg(my_cfg = "unk")]
//~^ WARNING unexpected `cfg` condition value
fn my_cfg() {}

fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/check-cfg/concat-values.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
warning: unexpected `cfg` condition value
--> $DIR/concat-values.rs:5:7
|
LL | #[cfg(my_cfg)]
| ^^^^^^
|
= note: expected values for `my_cfg` are: `bar`, `foo`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value
--> $DIR/concat-values.rs:9:7
|
LL | #[cfg(my_cfg = "unk")]
| ^^^^^^^^^^^^^^
|
= note: expected values for `my_cfg` are: `bar`, `foo`

warning: 2 warnings emitted

2 changes: 1 addition & 1 deletion tests/ui/check-cfg/diagnotics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --check-cfg=values(no_values) -Z unstable-options
// compile-flags: --check-cfg=exhaustive(names) --check-cfg=configure(feature,"foo") --check-cfg=configure(no_values) -Z unstable-options

#[cfg(featur)]
//~^ WARNING unexpected `cfg` condition name
Expand Down
10 changes: 0 additions & 10 deletions tests/ui/check-cfg/empty-names.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/check-cfg/empty-names.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/check-cfg/empty-values.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
warning: unexpected `cfg` condition name
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `empty_names_values` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 3 warnings emitted

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
warning: unexpected `cfg` condition name
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `exhaustive_names_values` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 3 warnings emitted

32 changes: 32 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
warning: unexpected `cfg` condition name
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `cfg` condition value
--> $DIR/exhaustive-names-values.rs:18:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^
|
= note: expected values for `feature` are: `std`

warning: unexpected `full` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 4 warnings emitted

31 changes: 31 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Check warning for unexpected cfg
//
// check-pass
// revisions: empty_names_values exhaustive_names_values full
// compile-flags: -Z unstable-options
// [empty_names_values]compile-flags: --check-cfg=names() --check-cfg=values()
// [exhaustive_names_values]compile-flags: --check-cfg=exhaustive(names,values)
// [full]compile-flags: --check-cfg=exhaustive(names,values) --check-cfg=configure(feature,"std")

#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}

#[cfg(test = "value")]
//~^ WARNING unexpected `cfg` condition value
pub fn f() {}

#[cfg(feature = "unk")]
//[full]~^ WARNING unexpected `cfg` condition value
pub fn feat() {}

#[cfg(feature = "std")]
pub fn feat() {}

#[cfg(windows)]
pub fn win() {}

#[cfg(unix)]
pub fn unix() {}

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/check-cfg/exhaustive-names.empty_names.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
warning: unexpected `cfg` condition name
--> $DIR/exhaustive-names.rs:8:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `empty_names` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 2 warnings emitted

14 changes: 14 additions & 0 deletions tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
warning: unexpected `cfg` condition name
--> $DIR/exhaustive-names.rs:8:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `exhaustive_names` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 2 warnings emitted

12 changes: 12 additions & 0 deletions tests/ui/check-cfg/exhaustive-names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Check warning for unexpected cfg
//
// check-pass
// revisions: empty_names exhaustive_names
// [empty_names]compile-flags: --check-cfg=names() -Z unstable-options
// [exhaustive_names]compile-flags: --check-cfg=exhaustive(names) -Z unstable-options

#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value
--> $DIR/empty-values.rs:6:7
--> $DIR/exhaustive-values.rs:8:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/exhaustive-values.exhaustive_values.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
warning: unexpected `cfg` condition value
--> $DIR/exhaustive-values.rs:8:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: 1 warning emitted

12 changes: 12 additions & 0 deletions tests/ui/check-cfg/exhaustive-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Check warning for unexpected cfg value
//
// check-pass
// revisions: empty_values exhaustive_values
// [empty_values]compile-flags: --check-cfg=values() -Z unstable-options
// [exhaustive_values]compile-flags: --check-cfg=exhaustive(values) -Z unstable-options

#[cfg(test = "value")]
//~^ WARNING unexpected `cfg` condition value
pub fn f() {}

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/invalid-arguments.anything_else.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
error: invalid `--check-cfg` argument: `anything_else(...)` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`)
error: invalid `--check-cfg` argument: `anything_else(...)` (expected `exhaustive(names, values)` or `configure(name, "value1", "value2", ... "valueN")`)

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `configure(foo,"NOT_IDENT",bar)` (`configure()` names cannot be after values)

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `configure("NOT_IDENT")` (`configure()` first arguments must be simple identifiers)

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `exhaustive("NOT_IDENT")` (`exhaustive()` arguments must be simple identifiers)

14 changes: 10 additions & 4 deletions tests/ui/check-cfg/invalid-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
//
// check-fail
// revisions: anything_else names_simple_ident values_simple_ident values_string_literals
// [anything_else]compile-flags: -Z unstable-options --check-cfg=anything_else(...)
// [names_simple_ident]compile-flags: -Z unstable-options --check-cfg=names("NOT_IDENT")
// [values_simple_ident]compile-flags: -Z unstable-options --check-cfg=values("NOT_IDENT")
// [values_string_literals]compile-flags: -Z unstable-options --check-cfg=values(test,12)
// revisions: exhaustive_simple_ident configure_simple_ident configure_ident_after
//
// compile-flags: -Z unstable-options
// [anything_else]compile-flags: --check-cfg=anything_else(...)
// [names_simple_ident]compile-flags: --check-cfg=names("NOT_IDENT")
// [values_simple_ident]compile-flags: --check-cfg=values("NOT_IDENT")
// [values_string_literals]compile-flags: --check-cfg=values(test,12)
// [exhaustive_simple_ident]compile-flags: --check-cfg=exhaustive("NOT_IDENT")
// [configure_simple_ident]compile-flags: --check-cfg=configure("NOT_IDENT")
// [configure_ident_after]compile-flags: --check-cfg=configure(foo,"NOT_IDENT",bar)

fn main() {}
Loading

0 comments on commit 6846f33

Please sign in to comment.