From a764d44f1720b913157d6cc112830f2f6f8ae0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 30 May 2022 16:21:03 +0000 Subject: [PATCH] update xshell to 0.2 (#4789) # Objective - Update xshell to 0.2 in ci tool - Replace #4205 --- tools/ci/Cargo.toml | 2 +- tools/ci/src/main.rs | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tools/ci/Cargo.toml b/tools/ci/Cargo.toml index 509d65db9074b..941bca58efc5d 100644 --- a/tools/ci/Cargo.toml +++ b/tools/ci/Cargo.toml @@ -7,5 +7,5 @@ publish = false license = "MIT OR Apache-2.0" [dependencies] -xshell = "0.1" +xshell = "0.2" bitflags = "1.3" diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 6326315d86f81..4b07c2d570381 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -1,4 +1,4 @@ -use xshell::{cmd, pushd}; +use xshell::{cmd, Shell}; use bitflags::bitflags; @@ -39,9 +39,11 @@ fn main() { _ => Check::all(), }; + let sh = Shell::new().unwrap(); + if what_to_run.contains(Check::FORMAT) { // See if any code needs to be formatted - cmd!("cargo fmt --all -- --check") + cmd!(sh, "cargo fmt --all -- --check") .run() .expect("Please run 'cargo fmt --all' to format your code."); } @@ -49,7 +51,7 @@ fn main() { if what_to_run.contains(Check::CLIPPY) { // See if clippy has any complaints. // - Type complexity must be ignored because we use huge templates for queries - cmd!("cargo clippy --workspace --all-targets --all-features -- -A clippy::type_complexity -W clippy::doc_markdown -D warnings") + cmd!(sh, "cargo clippy --workspace --all-targets --all-features -- -A clippy::type_complexity -W clippy::doc_markdown -D warnings") .run() .expect("Please fix clippy errors in output above."); } @@ -57,23 +59,22 @@ fn main() { if what_to_run.contains(Check::COMPILE_FAIL) { // Run UI tests (they do not get executed with the workspace tests) // - See crates/bevy_ecs_compile_fail_tests/README.md - let _bevy_ecs_compile_fail_tests = pushd("crates/bevy_ecs_compile_fail_tests") - .expect("Failed to navigate to the 'bevy_ecs_compile_fail_tests' crate"); - cmd!("cargo test --target-dir ../../target") + let _subdir = sh.push_dir("crates/bevy_ecs_compile_fail_tests"); + cmd!(sh, "cargo test --target-dir ../../target") .run() .expect("Compiler errors of the ECS compile fail tests seem to be different than expected! Check locally and compare rust versions."); } if what_to_run.contains(Check::TEST) { // Run tests (except doc tests and without building examples) - cmd!("cargo test --workspace --lib --bins --tests --benches") + cmd!(sh, "cargo test --workspace --lib --bins --tests --benches") .run() .expect("Please fix failing tests in output above."); } if what_to_run.contains(Check::DOC_TEST) { // Run doc tests - cmd!("cargo test --workspace --doc") + cmd!(sh, "cargo test --workspace --doc") .run() .expect("Please fix failing doc-tests in output above."); } @@ -81,29 +82,32 @@ fn main() { if what_to_run.contains(Check::DOC_CHECK) { // Check that building docs work and does not emit warnings std::env::set_var("RUSTDOCFLAGS", "-D warnings"); - cmd!("cargo doc --workspace --all-features --no-deps --document-private-items") - .run() - .expect("Please fix doc warnings in output above."); + cmd!( + sh, + "cargo doc --workspace --all-features --no-deps --document-private-items" + ) + .run() + .expect("Please fix doc warnings in output above."); } if what_to_run.contains(Check::COMPILE_FAIL) { + let _subdir = sh.push_dir("benches"); // Check that benches are building - let _benches = pushd("benches").expect("Failed to navigate to the 'benches' folder"); - cmd!("cargo check --benches --target-dir ../target") + cmd!(sh, "cargo check --benches --target-dir ../target") .run() .expect("Failed to check the benches."); } if what_to_run.contains(Check::EXAMPLE_CHECK) { // Build examples and check they compile - cmd!("cargo check --workspace --examples") + cmd!(sh, "cargo check --workspace --examples") .run() .expect("Please fix failing doc-tests in output above."); } if what_to_run.contains(Check::COMPILE_CHECK) { // Build examples and check they compile - cmd!("cargo check --workspace") + cmd!(sh, "cargo check --workspace") .run() .expect("Please fix failing doc-tests in output above."); }