From dd0cb68532eea6586b2685d7e5b3cc41b4ef5c73 Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Wed, 22 Nov 2023 13:12:56 +0300 Subject: [PATCH 1/2] Fix integration tests should panic if error occurs --- cargo-concordium/CHANGELOG.md | 2 ++ cargo-concordium/src/main.rs | 17 ++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cargo-concordium/CHANGELOG.md b/cargo-concordium/CHANGELOG.md index 82a07111..195a8f35 100644 --- a/cargo-concordium/CHANGELOG.md +++ b/cargo-concordium/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased changes +- Fix a bug so that a non-zero status code is now returned by the integration tests if they fail to run successfully. + ## 3.1.4 - Support crate names with uppercase letters. diff --git a/cargo-concordium/src/main.rs b/cargo-concordium/src/main.rs index 4d2b9b05..85ede9c4 100644 --- a/cargo-concordium/src/main.rs +++ b/cargo-concordium/src/main.rs @@ -645,19 +645,14 @@ pub fn main() -> anyhow::Result<()> { only_unit_tests, test_targets, } => { - let success_unit = build_and_run_wasm_test(&build_options.cargo_args, seed) - .context("Could not build and run tests.")?; - let success_integration = if only_unit_tests { - true - } else { - build_and_run_integration_tests(build_options, test_targets).is_ok() + build_and_run_wasm_test(&build_options.cargo_args, seed) + .context("Could not build and run unit tests.")?; + if !only_unit_tests { + build_and_run_integration_tests(build_options, test_targets) + .context("Could not build and run integration tests.")?; }; - if success_unit && success_integration { - eprintln!("{}", Color::Green.bold().paint("All tests passed")); - } else { - eprintln!("\n{}", Color::Red.bold().paint("One or more tests failed")); - }; + eprintln!("{}", Color::Green.bold().paint("All tests passed")); } Command::Init { path } => { init_concordium_project(path) From ceb760400378488b727249ddfe6636b6e1e62a34 Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Wed, 22 Nov 2023 16:16:56 +0300 Subject: [PATCH 2/2] Fix status code --- cargo-concordium/CHANGELOG.md | 2 +- cargo-concordium/src/main.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cargo-concordium/CHANGELOG.md b/cargo-concordium/CHANGELOG.md index 195a8f35..7b732487 100644 --- a/cargo-concordium/CHANGELOG.md +++ b/cargo-concordium/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased changes -- Fix a bug so that a non-zero status code is now returned by the integration tests if they fail to run successfully. +- Fix a bug so that a non-zero status code is now returned by `cargo concordium test` if tests fail. ## 3.1.4 diff --git a/cargo-concordium/src/main.rs b/cargo-concordium/src/main.rs index 85ede9c4..7ddec8ea 100644 --- a/cargo-concordium/src/main.rs +++ b/cargo-concordium/src/main.rs @@ -645,12 +645,15 @@ pub fn main() -> anyhow::Result<()> { only_unit_tests, test_targets, } => { - build_and_run_wasm_test(&build_options.cargo_args, seed) + let unit_test_success = build_and_run_wasm_test(&build_options.cargo_args, seed) .context("Could not build and run unit tests.")?; if !only_unit_tests { build_and_run_integration_tests(build_options, test_targets) .context("Could not build and run integration tests.")?; - }; + } + if !unit_test_success { + anyhow::bail!("One or more unit tests failed."); + } eprintln!("{}", Color::Green.bold().paint("All tests passed")); }