Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5853e6f

Browse files
committed
chore: add tests to check against the --test compile flag
1 parent c000a01 commit 5853e6f

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

‎tests/ui/exit1_compile_flag_test.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@compile-flags: --test
2+
#![warn(clippy::exit)]
3+
4+
fn not_main() {
5+
if true {
6+
std::process::exit(4);
7+
//~^ exit
8+
}
9+
}
10+
11+
fn main() {
12+
if true {
13+
std::process::exit(2);
14+
};
15+
not_main();
16+
std::process::exit(1);
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: usage of `process::exit`
2+
--> tests/ui/exit1_compile_flag_test.rs:6:9
3+
|
4+
LL | std::process::exit(4);
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::exit` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::exit)]`
9+
10+
error: aborting due to 1 previous error
11+

‎tests/ui/exit2_compile_flag_test.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@compile-flags: --test
2+
#![warn(clippy::exit)]
3+
4+
fn also_not_main() {
5+
std::process::exit(3);
6+
//~^ exit
7+
}
8+
9+
fn main() {
10+
if true {
11+
std::process::exit(2);
12+
};
13+
also_not_main();
14+
std::process::exit(1);
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: usage of `process::exit`
2+
--> tests/ui/exit2_compile_flag_test.rs:5:5
3+
|
4+
LL | std::process::exit(3);
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::exit` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::exit)]`
9+
10+
error: aborting due to 1 previous error
11+

‎tests/ui/exit3_compile_flag_test.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ check-pass
2+
//@compile-flags: --test
3+
4+
#![warn(clippy::exit)]
5+
6+
fn main() {
7+
if true {
8+
std::process::exit(2);
9+
};
10+
std::process::exit(1);
11+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /