Skip to content

Commit

Permalink
Update compile test to use ui_test 0.23 (#13245)
Browse files Browse the repository at this point in the history
# Objective

Closes #13241

## Solution

Update test utils to use `ui_test` 0.23.0.

## Testing

- Run compile tests for bevy_ecs.

cc @BD103
  • Loading branch information
Brezak authored May 5, 2024
1 parent a22eced commit 423a473
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exclude = [
"crates/bevy_derive/compile_fail",
"crates/bevy_ecs/compile_fail",
"crates/bevy_reflect/compile_fail",
"tools/compile_fail_utils",
]
members = [
"crates/*",
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_derive/compile_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
# ui_test dies if we don't specify the version. See oli-obk/ui_test#211
bevy_derive = { path = "../", version = "0.14.0-dev" }
bevy_derive = { path = "../" }

[dev-dependencies]
compile_fail_utils = { path = "../../../tools/compile_fail_utils" }
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/compile_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
# ui_test dies if we don't specify the version. See oli-obk/ui_test#211
bevy_ecs = { path = "../", version = "0.14.0-dev" }
bevy_ecs = { path = "../" }

[dev-dependencies]
compile_fail_utils = { path = "../../../tools/compile_fail_utils" }
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_reflect/compile_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
# ui_test dies if we don't specify the version. See oli-obk/ui_test#211
bevy_reflect = { path = "../", version = "0.14.0-dev" }
bevy_reflect = { path = "../" }

[dev-dependencies]
compile_fail_utils = { path = "../../../tools/compile_fail_utils" }
Expand Down
2 changes: 1 addition & 1 deletion tools/compile_fail_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
ui_test = "0.22.3"
ui_test = "0.23.0"

[[test]]
name = "example"
Expand Down
21 changes: 18 additions & 3 deletions tools/compile_fail_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ use std::{
pub use ui_test;

use ui_test::{
default_file_filter, default_per_file_config, run_tests_generic,
default_file_filter, default_per_file_config,
dependencies::DependencyBuilder,
run_tests_generic,
spanned::Spanned,
status_emitter::{Gha, StatusEmitter, Text},
Args, Config, OutputConflictHandling,
};

/// Use this instead of hand rolling configs.
///
/// `root_dir` is the directory your tests are contained in. Needs to be a path from crate root.
/// This config will build dependencies and will assume that the cargo manifest is placed at the
/// current working directory.
fn basic_config(root_dir: impl Into<PathBuf>, args: &Args) -> Config {
let mut config = Config {
dependencies_crate_manifest_path: Some("Cargo.toml".into()),
bless_command: Some("`cargo test` with the BLESS environment variable set to any non empty value".to_string()),
bless_command: Some(
"`cargo test` with the BLESS environment variable set to any non empty value"
.to_string(),
),
output_conflict_handling: if env::var_os("BLESS").is_some() {
OutputConflictHandling::Bless
} else {
Expand All @@ -45,6 +52,14 @@ fn basic_config(root_dir: impl Into<PathBuf>, args: &Args) -> Config {
"$HOME",
);

// Manually insert @aux-build:<dep> comments into test files. This needs to
// be done to build and link dependencies. Dependencies will be pulled from a
// Cargo.toml file.
config.comment_defaults.base().custom.insert(
"dependencies",
Spanned::dummy(vec![Box::new(DependencyBuilder::default())]),
);

config
}

Expand Down

0 comments on commit 423a473

Please sign in to comment.