bevy/tools/ci/src/commands/test.rs
Lucas Franca c8cb7bdf57
Allow passing number of thread for building and testing to CI (#19359)
# Objective

Fixes #16051
Closes #16145

## Solution

Allow passing `--build-jobs` and `--test-threads` to `ci`
i.e.
```
cargo run -p ci -- --build-jobs 4 --test-threads 4
```

## Testing

running ci locally

---------

Co-authored-by: Benjamin Brienen <Benjamin.Brienen@outlook.com>
2025-06-16 21:19:47 +00:00

27 lines
910 B
Rust

use crate::{args::Args, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;
/// Runs all tests (except for doc tests).
#[derive(FromArgs, Default)]
#[argh(subcommand, name = "test")]
pub struct TestCommand {}
impl Prepare for TestCommand {
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
let no_fail_fast = args.keep_going();
let jobs = args.build_jobs();
let test_threads = args.test_threads();
vec![PreparedCommand::new::<Self>(
cmd!(
sh,
// `--benches` runs each benchmark once in order to verify that they behave
// correctly and do not panic.
"cargo test --workspace --lib --bins --tests --benches {no_fail_fast...} {jobs...} -- {test_threads...}"
),
"Please fix failing tests in output above.",
)]
}
}