mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
'arc diff' passes the diff ID to Test Engine class.
Summary: Test Engine classes might need the differential Diff ID to be able to attach postponed test results to diffs. Test Plan: Added setDifferentialDiff function to PhutilUnitTestEngine class and made sure it was called with the correct diff ID when running 'arc diff --preview' Reviewed By: jungejason Reviewers: jungejason, grglr Commenters: sgrimm CC: epriestley, sgrimm, slawekbiel, aran, tuomaspelkonen, jungejason Differential Revision: 395
This commit is contained in:
parent
03056c7206
commit
fe9daa7ae3
3 changed files with 29 additions and 8 deletions
|
@ -26,6 +26,7 @@ abstract class ArcanistBaseUnitTestEngine {
|
||||||
private $workingCopy;
|
private $workingCopy;
|
||||||
private $paths;
|
private $paths;
|
||||||
private $arguments = array();
|
private $arguments = array();
|
||||||
|
protected $diffID;
|
||||||
|
|
||||||
final public function __construct() {
|
final public function __construct() {
|
||||||
|
|
||||||
|
@ -62,4 +63,12 @@ abstract class ArcanistBaseUnitTestEngine {
|
||||||
|
|
||||||
abstract public function run();
|
abstract public function run();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called after run() when the diff is created
|
||||||
|
* Child classes should override this function if they want to
|
||||||
|
* do more with the diff ID.
|
||||||
|
*/
|
||||||
|
public function setDifferentialDiffID($id) {
|
||||||
|
$this->diffID = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
|
||||||
private $unresolvedLint;
|
private $unresolvedLint;
|
||||||
private $unresolvedTests;
|
private $unresolvedTests;
|
||||||
private $diffID;
|
private $diffID;
|
||||||
|
private $unitWorkflow;
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
|
@ -295,6 +296,10 @@ EOTEXT
|
||||||
'differential.creatediff',
|
'differential.creatediff',
|
||||||
$diff);
|
$diff);
|
||||||
|
|
||||||
|
if ($this->unitWorkflow) {
|
||||||
|
$this->unitWorkflow->setDifferentialDiffID($diff_info['diffid']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->unresolvedLint) {
|
if ($this->unresolvedLint) {
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($this->unresolvedLint as $message) {
|
foreach ($this->unresolvedLint as $message) {
|
||||||
|
@ -1107,8 +1112,8 @@ EOTEXT
|
||||||
if ($repository_api instanceof ArcanistSubversionAPI) {
|
if ($repository_api instanceof ArcanistSubversionAPI) {
|
||||||
$argv = array_merge($argv, array_keys($paths));
|
$argv = array_merge($argv, array_keys($paths));
|
||||||
}
|
}
|
||||||
$unit_workflow = $this->buildChildWorkflow('unit', $argv);
|
$this->unitWorkflow = $this->buildChildWorkflow('unit', $argv);
|
||||||
$unit_result = $unit_workflow->run();
|
$unit_result = $this->unitWorkflow->run();
|
||||||
switch ($unit_result) {
|
switch ($unit_result) {
|
||||||
case ArcanistUnitWorkflow::RESULT_OKAY:
|
case ArcanistUnitWorkflow::RESULT_OKAY:
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
|
@ -1133,7 +1138,7 @@ EOTEXT
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->unresolvedTests = $unit_workflow->getUnresolvedTests();
|
$this->unresolvedTests = $this->unitWorkflow->getUnresolvedTests();
|
||||||
|
|
||||||
return $unit_result;
|
return $unit_result;
|
||||||
} catch (ArcanistNoEngineException $ex) {
|
} catch (ArcanistNoEngineException $ex) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ class ArcanistUnitWorkflow extends ArcanistBaseWorkflow {
|
||||||
const RESULT_SKIP = 3;
|
const RESULT_SKIP = 3;
|
||||||
|
|
||||||
private $unresolvedTests;
|
private $unresolvedTests;
|
||||||
|
private $engine;
|
||||||
|
|
||||||
public function getCommandHelp() {
|
public function getCommandHelp() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
|
@ -92,12 +93,12 @@ EOTEXT
|
||||||
|
|
||||||
|
|
||||||
PhutilSymbolLoader::loadClass($engine_class);
|
PhutilSymbolLoader::loadClass($engine_class);
|
||||||
$engine = newv($engine_class, array());
|
$this->engine = newv($engine_class, array());
|
||||||
$engine->setWorkingCopy($working_copy);
|
$this->engine->setWorkingCopy($working_copy);
|
||||||
$engine->setPaths($paths);
|
$this->engine->setPaths($paths);
|
||||||
$engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
|
$this->engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
|
||||||
|
|
||||||
$results = $engine->run();
|
$results = $this->engine->run();
|
||||||
|
|
||||||
$status_codes = array(
|
$status_codes = array(
|
||||||
ArcanistUnitTestResult::RESULT_PASS => phutil_console_format(
|
ArcanistUnitTestResult::RESULT_PASS => phutil_console_format(
|
||||||
|
@ -156,4 +157,10 @@ EOTEXT
|
||||||
return $this->unresolvedTests;
|
return $this->unresolvedTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDifferentialDiffID($id) {
|
||||||
|
if ($this->engine) {
|
||||||
|
$this->engine->setDifferentialDiffID($id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue