Skip to content

Commit 517f209

Browse files
committed
Merge branch 'create-ui-tests' into missing-reflect
2 parents 0ab38fe + ad94cda commit 517f209

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

bevy_lint/tests/ui.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,19 @@ fn config() -> color_eyre::Result<Config> {
8282
#[derive(Deserialize, Debug)]
8383
#[serde(rename = "compiler-artifact", tag = "reason")]
8484
struct ArtifactMessage<'a> {
85-
package_id: &'a str,
85+
#[serde(borrow)]
8686
target: ArtifactTarget<'a>,
87+
88+
#[serde(borrow)]
8789
filenames: Vec<&'a Path>,
8890
}
8991

9092
/// The `"target"` field of an [`ArtifactMessage`].
9193
#[derive(Deserialize, Debug)]
9294
struct ArtifactTarget<'a> {
9395
name: &'a str,
96+
97+
#[serde(borrow)]
9498
kind: Vec<&'a str>,
9599
}
96100

@@ -114,19 +118,17 @@ fn find_bevy_rlib() -> color_eyre::Result<PathBuf> {
114118

115119
ensure!(output.status.success(), "`cargo build --test=ui` failed.");
116120

117-
// The package ID of the `bevy` crate starts with this string.
118-
const BEVY_PACKAGE_ID_PREFIX: &str =
119-
"registry+https://github.com/rust-lang/crates.io-index#bevy@";
120-
121121
// It's theoretically possible for there to be multiple messages about building `libbevy.rlib`.
122122
// We support this, but optimize for just 1 message.
123123
let mut messages = Vec::with_capacity(1);
124124

125+
// Convert the `stdout` to a string, replacing invalid characters with `�`.
126+
let stdout = String::from_utf8_lossy(&output.stdout);
127+
125128
// Iterate over each line in stdout, trying to deserialize it from JSON.
126-
for line in output.stdout.split(|&byte| byte == b'\n') {
127-
if let Ok(message) = serde_json::from_slice::<ArtifactMessage>(line)
129+
for line in stdout.lines() {
130+
if let Ok(message) = serde_json::from_str::<ArtifactMessage>(line)
128131
// If the message passes the following conditions, it's probably the one we want.
129-
&& message.package_id.starts_with(BEVY_PACKAGE_ID_PREFIX)
130132
&& message.target.name == "bevy"
131133
&& message.target.kind.contains(&"lib")
132134
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(register_tool)]
2+
#![register_tool(bevy)]
3+
#![deny(bevy::main_return_without_appexit)]
4+
5+
use bevy::prelude::*;
6+
7+
fn main() {
8+
App::new().run();
9+
//~^ ERROR: an entrypoint that calls `App::run()` does not return `AppExit`
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: an entrypoint that calls `App::run()` does not return `AppExit`
2+
--> tests/ui/main_return_without_appexit.rs:8:16
3+
|
4+
7 | fn main() {
5+
| - help: try: `-> AppExit`
6+
8 | App::new().run();
7+
| ^^^^^
8+
|
9+
= note: `App::run()` returns `AppExit`, which can be used to determine whether the app exited successfully or not
10+
note: the lint level is defined here
11+
--> tests/ui/main_return_without_appexit.rs:3:9
12+
|
13+
3 | #![deny(bevy::main_return_without_appexit)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+
error: aborting due to 1 previous error
17+

0 commit comments

Comments
 (0)