Skip to content

Commit 7a81808

Browse files
committed
chore: create the #@exit-status: CODE annotation
This lets us verify a specific exit code is set by `bevy_lint`, rather than just ignoring it completely.
1 parent 747c7b9 commit 7a81808

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/long_version_format/fail/Cargo.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: multiple versions of the `bevy` crate found
2-
--> Cargo.toml:12:26
2+
--> Cargo.toml:14:26
33
|
4-
12 | leafwing-input-manager = "0.13"
4+
14 | leafwing-input-manager = "0.13"
55
| ^^^^^^
66
|
77
help: expected all crates to use `bevy` 0.17.2, but `leafwing-input-manager` uses `bevy` ^0.13
8-
--> Cargo.toml:11:8
8+
--> Cargo.toml:13:8
99
|
10-
11 | bevy = { version = "0.17.2", default-features = false }
10+
13 | bevy = { version = "0.17.2", default-features = false }
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
note: the lint level is defined here
1313
--> src/main.rs:3:9

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/long_version_format/fail/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#@exit-status: 101
2+
13
[package]
24
name = "multiple-bevy-versions"
35
publish = false

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/long_version_format/pass/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#@check-pass
2+
13
[package]
24
name = "single-bevy-version"
35
publish = false

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/short_version_format/fail/Cargo.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: multiple versions of the `bevy` crate found
2-
--> Cargo.toml:12:26
2+
--> Cargo.toml:14:26
33
|
4-
12 | leafwing-input-manager = "0.13"
4+
14 | leafwing-input-manager = "0.13"
55
| ^^^^^^
66
|
77
help: expected all crates to use `bevy` 0.17.2, but `leafwing-input-manager` uses `bevy` ^0.13
8-
--> Cargo.toml:11:8
8+
--> Cargo.toml:13:8
99
|
10-
11 | bevy = "0.17.2"
10+
13 | bevy = "0.17.2"
1111
| ^^^^^^^^
1212
note: the lint level is defined here
1313
--> src/main.rs:3:9

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/short_version_format/fail/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#@exit-status: 101
2+
13
[package]
24
name = "multiple-bevy-versions"
35
publish = false

bevy_lint/tests/ui-cargo/duplicate_bevy_dependencies/short_version_format/pass/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#@check-pass
2+
13
[package]
24
name = "single-bevy-version"
35
publish = false

bevy_lint/tests/ui_cargo.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
process::{Command, Stdio},
55
};
66

7-
use ui_test::{CommandBuilder, Config, status_emitter};
7+
use ui_test::{CommandBuilder, Config, OptWithLine, status_emitter};
88

99
// This is set by Cargo to the absolute paths of `bevy_lint` and `bevy_lint_driver`.
1010
const LINTER_PATH: &str = env!("CARGO_BIN_EXE_bevy_lint");
@@ -36,12 +36,21 @@ fn main() {
3636
};
3737

3838
let defaults = config.comment_defaults.base();
39-
// The driver returns a '101' on error.
40-
// This allows for any status code to be considered a success.
41-
defaults.exit_status = None.into();
42-
4339
defaults.require_annotations = None.into();
4440

41+
// Create the `#@exit-status: CODE` annotation. This can be used to ensure a UI test exits with
42+
// a specific exit code (e.g. `bevy_lint` exits with code 101 when a denied lint is found).
43+
config
44+
.custom_comments
45+
.insert("exit-status", |parser, args, _span| {
46+
parser.exit_status = OptWithLine::new(
47+
args.content
48+
.parse()
49+
.expect("expected `i32` as input for `exit-status`"),
50+
args.span,
51+
);
52+
});
53+
4554
// Run this `Config` for all paths that end with `Cargo.toml` resulting
4655
// only in the `Cargo` lints.
4756
ui_test::run_tests_generic(

0 commit comments

Comments
 (0)