Skip to content

Commit

Permalink
Split tests in unix/non-unix
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroto committed Apr 26, 2020
1 parent 4a405c9 commit 303e7d1
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 94 deletions.
30 changes: 30 additions & 0 deletions tests/ui/mismatched_target_os_non_unix.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// run-rustfix

#![warn(clippy::mismatched_target_os)]
#![allow(unused)]

#[cfg(target_os = "cloudabi")]
fn cloudabi() {}

#[cfg(target_os = "hermit")]
fn hermit() {}

#[cfg(target_os = "wasi")]
fn wasi() {}

#[cfg(target_os = "none")]
fn none() {}

// list with conditions
#[cfg(all(not(any(windows, target_os = "cloudabi")), target_os = "wasi"))]
fn list() {}

// windows is a valid target family, should be ignored
#[cfg(windows)]
fn windows() {}

// correct use, should be ignored
#[cfg(target_os = "hermit")]
fn correct() {}

fn main() {}
30 changes: 30 additions & 0 deletions tests/ui/mismatched_target_os_non_unix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// run-rustfix

#![warn(clippy::mismatched_target_os)]
#![allow(unused)]

#[cfg(cloudabi)]
fn cloudabi() {}

#[cfg(hermit)]
fn hermit() {}

#[cfg(wasi)]
fn wasi() {}

#[cfg(none)]
fn none() {}

// list with conditions
#[cfg(all(not(any(windows, cloudabi)), wasi))]
fn list() {}

// windows is a valid target family, should be ignored
#[cfg(windows)]
fn windows() {}

// correct use, should be ignored
#[cfg(target_os = "hermit")]
fn correct() {}

fn main() {}
51 changes: 51 additions & 0 deletions tests/ui/mismatched_target_os_non_unix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
error: operating system used in target family position
--> $DIR/mismatched_target_os_non_unix.rs:6:1
|
LL | #[cfg(cloudabi)]
| ^^^^^^--------^^
| |
| help: try: `target_os = "cloudabi"`
|
= note: `-D clippy::mismatched-target-os` implied by `-D warnings`

error: operating system used in target family position
--> $DIR/mismatched_target_os_non_unix.rs:9:1
|
LL | #[cfg(hermit)]
| ^^^^^^------^^
| |
| help: try: `target_os = "hermit"`

error: operating system used in target family position
--> $DIR/mismatched_target_os_non_unix.rs:12:1
|
LL | #[cfg(wasi)]
| ^^^^^^----^^
| |
| help: try: `target_os = "wasi"`

error: operating system used in target family position
--> $DIR/mismatched_target_os_non_unix.rs:15:1
|
LL | #[cfg(none)]
| ^^^^^^----^^
| |
| help: try: `target_os = "none"`

error: operating system used in target family position
--> $DIR/mismatched_target_os_non_unix.rs:19:1
|
LL | #[cfg(all(not(any(windows, cloudabi)), wasi))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL | #[cfg(all(not(any(windows, target_os = "cloudabi")), wasi))]
| ^^^^^^^^^^^^^^^^^^^^^^
help: try
|
LL | #[cfg(all(not(any(windows, cloudabi)), target_os = "wasi"))]
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#![warn(clippy::mismatched_target_os)]
#![allow(unused)]

// unix

#[cfg(target_os = "linux")]
fn linux() {}

Expand Down Expand Up @@ -38,6 +36,12 @@ fn fuchsia() {}
#[cfg(target_os = "haiku")]
fn haiku() {}

#[cfg(target_os = "illumos")]
fn illumos() {}

#[cfg(target_os = "l4re")]
fn l4re() {}

#[cfg(target_os = "redox")]
fn redox() {}

Expand All @@ -47,30 +51,12 @@ fn solaris() {}
#[cfg(target_os = "vxworks")]
fn vxworks() {}

// non-unix

#[cfg(target_os = "cloudabi")]
fn cloudabi() {}

#[cfg(target_os = "hermit")]
fn hermit() {}

#[cfg(target_os = "wasi")]
fn wasi() {}

#[cfg(target_os = "none")]
fn none() {}

// list with conditions
#[cfg(all(not(any(windows, target_os = "linux")), target_os = "freebsd"))]
#[cfg(all(not(any(target_os = "solaris", target_os = "linux")), target_os = "freebsd"))]
fn list() {}

// windows is a valid target family, should be ignored
#[cfg(windows)]
fn windows() {}

// correct use, should be ignored
#[cfg(target_os = "freebsd")]
fn freebsd() {}
fn correct() {}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#![warn(clippy::mismatched_target_os)]
#![allow(unused)]

// unix

#[cfg(linux)]
fn linux() {}

Expand Down Expand Up @@ -38,6 +36,12 @@ fn fuchsia() {}
#[cfg(haiku)]
fn haiku() {}

#[cfg(illumos)]
fn illumos() {}

#[cfg(l4re)]
fn l4re() {}

#[cfg(redox)]
fn redox() {}

Expand All @@ -47,30 +51,12 @@ fn solaris() {}
#[cfg(vxworks)]
fn vxworks() {}

// non-unix

#[cfg(cloudabi)]
fn cloudabi() {}

#[cfg(hermit)]
fn hermit() {}

#[cfg(wasi)]
fn wasi() {}

#[cfg(none)]
fn none() {}

// list with conditions
#[cfg(all(not(any(windows, linux)), freebsd))]
#[cfg(all(not(any(solaris, linux)), freebsd))]
fn list() {}

// windows is a valid target family, should be ignored
#[cfg(windows)]
fn windows() {}

// correct use, should be ignored
#[cfg(target_os = "freebsd")]
fn freebsd() {}
fn correct() {}

fn main() {}
Loading

0 comments on commit 303e7d1

Please sign in to comment.