-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proper integration tests that are separate from the workspace.
While this does not catch RA errors it should simulate bevy users better.
- Loading branch information
Showing
11 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ crates/**/target | |
benches/**/target | ||
tools/**/target | ||
**/*.rs.bk | ||
rustc-ice-*.txt | ||
|
||
# Cargo | ||
Cargo.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "simple-ecs-test" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bevy = { path = "../../" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![allow(dead_code)] | ||
use bevy::prelude::*; | ||
|
||
#[derive(Component)] | ||
struct _Component { | ||
_value: f32, | ||
} | ||
|
||
#[derive(Resource)] | ||
struct _Resource { | ||
_value: f32, | ||
} | ||
|
||
fn hello_world() { | ||
println!("hello world!"); | ||
} | ||
|
||
#[test] | ||
fn simple_ecs_test() { | ||
App::new().add_systems(Update, hello_world).run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::{commands::get_integration_tests, Flag, Prepare, PreparedCommand}; | ||
use argh::FromArgs; | ||
use xshell::cmd; | ||
|
||
/// Runs all integration tests (except for doc tests). | ||
#[derive(FromArgs, Default)] | ||
#[argh(subcommand, name = "integration-test")] | ||
pub struct IntegrationTestCommand {} | ||
|
||
impl Prepare for IntegrationTestCommand { | ||
fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec<PreparedCommand<'a>> { | ||
let no_fail_fast = flags | ||
.contains(Flag::KEEP_GOING) | ||
.then_some("--no-fail-fast") | ||
.unwrap_or_default(); | ||
|
||
get_integration_tests(sh) | ||
.into_iter() | ||
.map(|path| { | ||
PreparedCommand::new::<Self>( | ||
cmd!( | ||
sh, | ||
"cargo test --manifest-path {path}/Cargo.toml --tests {no_fail_fast}" | ||
), | ||
"Please fix failing integration tests in output above.", | ||
) | ||
}) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::path::Path; | ||
|
||
use crate::{Flag, Prepare, PreparedCommand}; | ||
use argh::FromArgs; | ||
use xshell::cmd; | ||
|
||
pub fn get_integration_tests(sh: &xshell::Shell) -> Vec<String> { | ||
let integration_test_paths = sh.read_dir(Path::new("./tests-integration")).unwrap(); | ||
|
||
// Filter out non-directories | ||
integration_test_paths | ||
.into_iter() | ||
.filter(|path| path.is_dir()) | ||
.map(|path| path.to_string_lossy().to_string()) | ||
.collect() | ||
} | ||
|
||
/// Checks that all integration tests compile. | ||
#[derive(FromArgs, Default)] | ||
#[argh(subcommand, name = "integration-test-check")] | ||
pub struct IntegrationTestCheckCommand {} | ||
|
||
impl Prepare for IntegrationTestCheckCommand { | ||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec<PreparedCommand<'a>> { | ||
get_integration_tests(sh) | ||
.into_iter() | ||
.map(|path| { | ||
PreparedCommand::new::<Self>( | ||
cmd!(sh, "cargo check --manifest-path {path}/Cargo.toml --tests"), | ||
"Please fix compiler errors for tests in output above.", | ||
) | ||
}) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::{Flag, Prepare, PreparedCommand}; | ||
use argh::FromArgs; | ||
use xshell::cmd; | ||
|
||
use super::get_integration_tests; | ||
|
||
/// Cleans the build artifacts for all integration tests. | ||
#[derive(FromArgs, Default)] | ||
#[argh(subcommand, name = "integration-test-clean")] | ||
pub struct IntegrationTestCleanCommand {} | ||
|
||
impl Prepare for IntegrationTestCleanCommand { | ||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec<PreparedCommand<'a>> { | ||
get_integration_tests(sh) | ||
.into_iter() | ||
.map(|path| { | ||
PreparedCommand::new::<Self>( | ||
cmd!(sh, "cargo clean --manifest-path {path}/Cargo.toml"), | ||
"Failed to clean integration test.", | ||
) | ||
}) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters