diff --git a/cli/src/main.rs b/cli/src/main.rs index e132bc21..4062c665 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -195,18 +195,16 @@ async fn run_upload( let failures = extract_failed_tests(&repo, &org_url_slug, &file_sets).await?; // Run the quarantine step and update the exit code. + let exit_code = if failures.is_empty() { + EXIT_SUCCESS + } else { + EXIT_FAILURE + }; let quarantine_run_results = if use_quarantining && quarantine_results.is_none() { Some( run_quarantine( - &RunResult { - exit_code: if failures.is_empty() { - EXIT_SUCCESS - } else { - EXIT_FAILURE - }, - failures, - exec_start: None, - }, + exit_code, + failures, &api_address, &token, &org_url_slug, @@ -375,11 +373,13 @@ async fn run_test(test_args: TestArgs) -> anyhow::Result { }); let run_exit_code = run_result.exit_code; + let failures = run_result.failures; let quarantine_run_result = if *use_quarantining { Some( run_quarantine( - &run_result, + run_exit_code, + failures, &api_address, token, org_url_slug, @@ -397,12 +397,13 @@ async fn run_test(test_args: TestArgs) -> anyhow::Result { .map(|r| r.exit_code) .unwrap_or(run_exit_code); + let exec_start = run_result.exec_start; match run_upload( upload_args, Some(command.join(" ")), None, // don't re-run quarantine checks codeowners, - run_result.exec_start, + exec_start, ) .await { diff --git a/cli/src/runner.rs b/cli/src/runner.rs index 39be4bfa..a79d83fd 100644 --- a/cli/src/runner.rs +++ b/cli/src/runner.rs @@ -157,14 +157,15 @@ pub async fn extract_failed_tests( } pub async fn run_quarantine( - run_result: &RunResult, + exit_code: i32, + failures: Vec, api_address: &str, token: &str, org_url_slug: &str, repo: &BundleRepo, delay: std::iter::Take, ) -> anyhow::Result { - let quarantine_config: QuarantineConfig = if !run_result.failures.is_empty() { + let quarantine_config: QuarantineConfig = if !failures.is_empty() { log::info!("Quarantining failed tests"); let result = Retry::spawn(delay, || { get_quarantining_config(api_address, token, org_url_slug, &repo.repo) @@ -183,9 +184,8 @@ pub async fn run_quarantine( // quarantine the failed tests let mut quarantine_results = QuarantineBulkTestStatus::default(); let quarantined = quarantine_config.quarantined_tests; - let total_failures = run_result.failures.len(); - quarantine_results.quarantine_results = run_result - .failures + let total_failures = failures.len(); + quarantine_results.quarantine_results = failures .clone() .into_iter() .filter_map(|failure| { @@ -215,12 +215,12 @@ pub async fn run_quarantine( // override exit code to be exit_success if the group is quarantined let exit_code = if !quarantine_results.group_is_quarantined { log::info!("Not all test failures were quarantined, returning exit code from command."); - run_result.exit_code - } else if run_result.exit_code != EXIT_SUCCESS && !quarantine_config.is_preview_mode { + exit_code + } else if exit_code != EXIT_SUCCESS && !quarantine_config.is_preview_mode { log::info!("All test failures were quarantined, overriding exit code to be exit_success"); EXIT_SUCCESS } else { - run_result.exit_code + exit_code }; Ok(QuarantineRunResult {