update xshell to 0.2 (#4789)

# Objective

- Update xshell to 0.2 in ci tool
- Replace #4205
This commit is contained in:
François 2022-05-30 16:21:03 +00:00
parent deeaf64897
commit a764d44f17
2 changed files with 20 additions and 16 deletions

View File

@ -7,5 +7,5 @@ publish = false
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
xshell = "0.1" xshell = "0.2"
bitflags = "1.3" bitflags = "1.3"

View File

@ -1,4 +1,4 @@
use xshell::{cmd, pushd}; use xshell::{cmd, Shell};
use bitflags::bitflags; use bitflags::bitflags;
@ -39,9 +39,11 @@ fn main() {
_ => Check::all(), _ => Check::all(),
}; };
let sh = Shell::new().unwrap();
if what_to_run.contains(Check::FORMAT) { if what_to_run.contains(Check::FORMAT) {
// See if any code needs to be formatted // See if any code needs to be formatted
cmd!("cargo fmt --all -- --check") cmd!(sh, "cargo fmt --all -- --check")
.run() .run()
.expect("Please run 'cargo fmt --all' to format your code."); .expect("Please run 'cargo fmt --all' to format your code.");
} }
@ -49,7 +51,7 @@ fn main() {
if what_to_run.contains(Check::CLIPPY) { if what_to_run.contains(Check::CLIPPY) {
// See if clippy has any complaints. // See if clippy has any complaints.
// - Type complexity must be ignored because we use huge templates for queries // - 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() .run()
.expect("Please fix clippy errors in output above."); .expect("Please fix clippy errors in output above.");
} }
@ -57,23 +59,22 @@ fn main() {
if what_to_run.contains(Check::COMPILE_FAIL) { if what_to_run.contains(Check::COMPILE_FAIL) {
// Run UI tests (they do not get executed with the workspace tests) // Run UI tests (they do not get executed with the workspace tests)
// - See crates/bevy_ecs_compile_fail_tests/README.md // - See crates/bevy_ecs_compile_fail_tests/README.md
let _bevy_ecs_compile_fail_tests = pushd("crates/bevy_ecs_compile_fail_tests") let _subdir = sh.push_dir("crates/bevy_ecs_compile_fail_tests");
.expect("Failed to navigate to the 'bevy_ecs_compile_fail_tests' crate"); cmd!(sh, "cargo test --target-dir ../../target")
cmd!("cargo test --target-dir ../../target")
.run() .run()
.expect("Compiler errors of the ECS compile fail tests seem to be different than expected! Check locally and compare rust versions."); .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) { if what_to_run.contains(Check::TEST) {
// Run tests (except doc tests and without building examples) // 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() .run()
.expect("Please fix failing tests in output above."); .expect("Please fix failing tests in output above.");
} }
if what_to_run.contains(Check::DOC_TEST) { if what_to_run.contains(Check::DOC_TEST) {
// Run doc tests // Run doc tests
cmd!("cargo test --workspace --doc") cmd!(sh, "cargo test --workspace --doc")
.run() .run()
.expect("Please fix failing doc-tests in output above."); .expect("Please fix failing doc-tests in output above.");
} }
@ -81,29 +82,32 @@ fn main() {
if what_to_run.contains(Check::DOC_CHECK) { if what_to_run.contains(Check::DOC_CHECK) {
// Check that building docs work and does not emit warnings // Check that building docs work and does not emit warnings
std::env::set_var("RUSTDOCFLAGS", "-D warnings"); std::env::set_var("RUSTDOCFLAGS", "-D warnings");
cmd!("cargo doc --workspace --all-features --no-deps --document-private-items") cmd!(
sh,
"cargo doc --workspace --all-features --no-deps --document-private-items"
)
.run() .run()
.expect("Please fix doc warnings in output above."); .expect("Please fix doc warnings in output above.");
} }
if what_to_run.contains(Check::COMPILE_FAIL) { if what_to_run.contains(Check::COMPILE_FAIL) {
let _subdir = sh.push_dir("benches");
// Check that benches are building // Check that benches are building
let _benches = pushd("benches").expect("Failed to navigate to the 'benches' folder"); cmd!(sh, "cargo check --benches --target-dir ../target")
cmd!("cargo check --benches --target-dir ../target")
.run() .run()
.expect("Failed to check the benches."); .expect("Failed to check the benches.");
} }
if what_to_run.contains(Check::EXAMPLE_CHECK) { if what_to_run.contains(Check::EXAMPLE_CHECK) {
// Build examples and check they compile // Build examples and check they compile
cmd!("cargo check --workspace --examples") cmd!(sh, "cargo check --workspace --examples")
.run() .run()
.expect("Please fix failing doc-tests in output above."); .expect("Please fix failing doc-tests in output above.");
} }
if what_to_run.contains(Check::COMPILE_CHECK) { if what_to_run.contains(Check::COMPILE_CHECK) {
// Build examples and check they compile // Build examples and check they compile
cmd!("cargo check --workspace") cmd!(sh, "cargo check --workspace")
.run() .run()
.expect("Please fix failing doc-tests in output above."); .expect("Please fix failing doc-tests in output above.");
} }