mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Fix unit test updates so a diff update has a predictable unit test status
Test Plan: Tested with various unit test states and noted that the worst unit test result was always the state used for the entire diff. Reviewers: nh, epriestley Reviewed By: nh Differential Revision https://secure.phabricator.com/D3465
This commit is contained in:
parent
fc0a7bf302
commit
f1d4755c61
1 changed files with 32 additions and 16 deletions
|
@ -108,17 +108,12 @@ final class ConduitAPI_differential_updateunitresults_Method
|
||||||
$unit_status = $result;
|
$unit_status = $result;
|
||||||
$unit_results[] = $unit_result;
|
$unit_results[] = $unit_result;
|
||||||
}
|
}
|
||||||
|
unset($unit_result);
|
||||||
|
|
||||||
$diff_property->setData($unit_results);
|
$diff_property->setData($unit_results);
|
||||||
$diff_property->save();
|
$diff_property->save();
|
||||||
|
|
||||||
foreach ($unit_results as $unit_result) {
|
// Map external unit test status to internal overall diff status
|
||||||
if ($unit_result['result'] ==
|
|
||||||
DifferentialUnitTestResult::RESULT_POSTPONED) {
|
|
||||||
$postponed_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$status_codes =
|
$status_codes =
|
||||||
array(
|
array(
|
||||||
DifferentialUnitTestResult::RESULT_PASS =>
|
DifferentialUnitTestResult::RESULT_PASS =>
|
||||||
|
@ -127,22 +122,43 @@ final class ConduitAPI_differential_updateunitresults_Method
|
||||||
DifferentialUnitStatus::UNIT_WARN,
|
DifferentialUnitStatus::UNIT_WARN,
|
||||||
DifferentialUnitTestResult::RESULT_FAIL =>
|
DifferentialUnitTestResult::RESULT_FAIL =>
|
||||||
DifferentialUnitStatus::UNIT_FAIL,
|
DifferentialUnitStatus::UNIT_FAIL,
|
||||||
|
DifferentialUnitTestResult::RESULT_BROKEN =>
|
||||||
|
DifferentialUnitStatus::UNIT_FAIL,
|
||||||
DifferentialUnitTestResult::RESULT_SKIP =>
|
DifferentialUnitTestResult::RESULT_SKIP =>
|
||||||
DifferentialUnitStatus::UNIT_OKAY,
|
DifferentialUnitStatus::UNIT_OKAY,
|
||||||
DifferentialUnitTestResult::RESULT_POSTPONED =>
|
DifferentialUnitTestResult::RESULT_POSTPONED =>
|
||||||
DifferentialUnitStatus::UNIT_POSTPONED);
|
DifferentialUnitStatus::UNIT_POSTPONED);
|
||||||
|
|
||||||
if ($diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
|
// These are the relative priorities for the unit test results
|
||||||
$status_code =
|
$status_codes_priority =
|
||||||
idx($status_codes, $unit_status, DifferentialUnitStatus::UNIT_NONE);
|
array(
|
||||||
if ($postponed_count == 0 ||
|
DifferentialUnitStatus::UNIT_OKAY => 1,
|
||||||
$status_code != DifferentialUnitStatus::UNIT_OKAY) {
|
DifferentialUnitStatus::UNIT_WARN => 2,
|
||||||
$diff->setUnitStatus($status_code);
|
DifferentialUnitStatus::UNIT_POSTPONED => 3,
|
||||||
|
DifferentialUnitStatus::UNIT_FAIL => 4);
|
||||||
|
|
||||||
|
// Walk the now-current list of status codes to find the overall diff
|
||||||
|
// status
|
||||||
|
$final_diff_status = DifferentialUnitStatus::UNIT_NONE;
|
||||||
|
foreach ($unit_results as $unit_result) {
|
||||||
|
// Convert the text result into a diff unit status value
|
||||||
|
$status_code = idx($status_codes,
|
||||||
|
$unit_result['result'],
|
||||||
|
DifferentialUnitStatus::UNIT_NONE);
|
||||||
|
|
||||||
|
// Convert the unit status into a relative value
|
||||||
|
$diff_status_priority = idx($status_codes_priority, $status_code, 0);
|
||||||
|
|
||||||
|
// If the relative value of this result is "more bad" than previous
|
||||||
|
// results, use it as the new final diff status
|
||||||
|
if ($diff_status_priority > idx($status_codes_priority,
|
||||||
|
$final_diff_status, 0)) {
|
||||||
|
$final_diff_status = $status_code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update our unit test result status with the final value
|
||||||
|
$diff->setUnitStatus($final_diff_status);
|
||||||
$diff->save();
|
$diff->save();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue