Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gnalh committed Sep 10, 2024
1 parent cc151ec commit bd30862
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
23 changes: 12 additions & 11 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -375,11 +373,13 @@ async fn run_test(test_args: TestArgs) -> anyhow::Result<i32> {
});

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,
Expand All @@ -397,12 +397,13 @@ async fn run_test(test_args: TestArgs) -> anyhow::Result<i32> {
.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
{
Expand Down
16 changes: 8 additions & 8 deletions cli/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ pub async fn extract_failed_tests(
}

pub async fn run_quarantine(
run_result: &RunResult,
exit_code: i32,
failures: Vec<Test>,
api_address: &str,
token: &str,
org_url_slug: &str,
repo: &BundleRepo,
delay: std::iter::Take<ExponentialBackoff>,
) -> anyhow::Result<QuarantineRunResult> {
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)
Expand All @@ -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| {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bd30862

Please sign in to comment.