diff options
| author | Ses Goe <jsesgoe@gmail.com> | 2025-07-07 15:08:38 -0400 |
|---|---|---|
| committer | Ses Goe <jsesgoe@gmail.com> | 2025-07-07 15:11:30 -0400 |
| commit | 5853e6fa7e951a880dea88fc1076ef43827e6c32 (patch) | |
| tree | 9387426e4253f6e301a691614c3f83b876369800 | |
| parent | c000a0136ccec78d3a7d6cf5ad0422eeb13bf9eb (diff) | |
| download | rust-5853e6fa7e951a880dea88fc1076ef43827e6c32.tar.gz rust-5853e6fa7e951a880dea88fc1076ef43827e6c32.zip | |
chore: add tests to check against the --test compile flag
| -rw-r--r-- | tests/ui/exit1_compile_flag_test.rs | 17 | ||||
| -rw-r--r-- | tests/ui/exit1_compile_flag_test.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/exit2_compile_flag_test.rs | 15 | ||||
| -rw-r--r-- | tests/ui/exit2_compile_flag_test.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/exit3_compile_flag_test.rs | 11 |
5 files changed, 65 insertions, 0 deletions
diff --git a/tests/ui/exit1_compile_flag_test.rs b/tests/ui/exit1_compile_flag_test.rs new file mode 100644 index 00000000000..9f83ed32533 --- /dev/null +++ b/tests/ui/exit1_compile_flag_test.rs @@ -0,0 +1,17 @@ +//@compile-flags: --test +#![warn(clippy::exit)] + +fn not_main() { + if true { + std::process::exit(4); + //~^ exit + } +} + +fn main() { + if true { + std::process::exit(2); + }; + not_main(); + std::process::exit(1); +} diff --git a/tests/ui/exit1_compile_flag_test.stderr b/tests/ui/exit1_compile_flag_test.stderr new file mode 100644 index 00000000000..6e33c39f0d7 --- /dev/null +++ b/tests/ui/exit1_compile_flag_test.stderr @@ -0,0 +1,11 @@ +error: usage of `process::exit` + --> tests/ui/exit1_compile_flag_test.rs:6:9 + | +LL | std::process::exit(4); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::exit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::exit)]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/exit2_compile_flag_test.rs b/tests/ui/exit2_compile_flag_test.rs new file mode 100644 index 00000000000..0b994ebc56c --- /dev/null +++ b/tests/ui/exit2_compile_flag_test.rs @@ -0,0 +1,15 @@ +//@compile-flags: --test +#![warn(clippy::exit)] + +fn also_not_main() { + std::process::exit(3); + //~^ exit +} + +fn main() { + if true { + std::process::exit(2); + }; + also_not_main(); + std::process::exit(1); +} diff --git a/tests/ui/exit2_compile_flag_test.stderr b/tests/ui/exit2_compile_flag_test.stderr new file mode 100644 index 00000000000..51eb26e9c2a --- /dev/null +++ b/tests/ui/exit2_compile_flag_test.stderr @@ -0,0 +1,11 @@ +error: usage of `process::exit` + --> tests/ui/exit2_compile_flag_test.rs:5:5 + | +LL | std::process::exit(3); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::exit` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::exit)]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/exit3_compile_flag_test.rs b/tests/ui/exit3_compile_flag_test.rs new file mode 100644 index 00000000000..f8131ead2da --- /dev/null +++ b/tests/ui/exit3_compile_flag_test.rs @@ -0,0 +1,11 @@ +//@ check-pass +//@compile-flags: --test + +#![warn(clippy::exit)] + +fn main() { + if true { + std::process::exit(2); + }; + std::process::exit(1); +} |
