1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 00:42:40 +01:00

Merge branch 'master' of github.com:facebook/arcanist

This commit is contained in:
epriestley 2011-02-03 16:00:05 -08:00
commit 89a3606406
5 changed files with 52 additions and 14 deletions

View file

@ -20,6 +20,7 @@ abstract class ArcanistBaseUnitTestEngine {
private $workingCopy;
private $paths;
private $arguments = array();
final public function __construct() {
@ -45,6 +46,15 @@ abstract class ArcanistBaseUnitTestEngine {
return $this->paths;
}
final public function setArguments(array $arguments) {
$this->arguments = $arguments;
return $this;
}
final public function getArgument($key, $default = null) {
return idx($this->arguments, $key, $default);
}
abstract public function run();
}

View file

@ -6,5 +6,7 @@
phutil_require_module('phutil', 'utils');
phutil_require_source('ArcanistBaseUnitTestEngine.php');

View file

@ -555,4 +555,29 @@ class ArcanistBaseWorkflow {
return array('any');
}
protected function getPassthruArgumentsAsMap($command) {
$map = array();
foreach ($this->getCompleteArgumentSpecification() as $key => $spec) {
if (!empty($spec['passthru'][$command])) {
if (isset($this->arguments[$key])) {
$map[$key] = $this->arguments[$key];
}
}
}
return $map;
}
protected function getPassthruArgumentsAsArgv($command) {
$spec = $this->getCompleteArgumentSpecification();
$map = $this->getPassthruArgumentsAsMap($command);
$argv = array();
foreach ($map as $key => $value) {
$argv[] = '--'.$key;
if (!empty($spec[$key]['param'])) {
$argv[] = $value;
}
}
return $argv;
}
}

View file

@ -149,10 +149,16 @@ EOTEXT
'lintall' => array(
'help' =>
"Raise all lint warnings, not just those on lines you changed.",
'passthru' => array(
'lint' => true,
),
),
'advice' => array(
'help' =>
"Raise lint advice in addition to lint warnings and errors.",
'passthru' => array(
'lint' => true,
),
),
'apply-patches' => array(
'help' =>
@ -161,12 +167,18 @@ EOTEXT
'conflicts' => array(
'never-apply-patches' => true,
),
'passthru' => array(
'lint' => true,
),
),
'never-apply-patches' => array(
'help' => 'Never apply patches suggested by lint.',
'conflicts' => array(
'apply-patches' => true,
),
'passthru' => array(
'lint' => true,
),
),
'*' => 'paths',
);
@ -836,19 +848,7 @@ EOTEXT
echo "Linting...\n";
try {
$argv = array();
if ($this->getArgument('lintall')) {
$argv[] = '--lintall';
}
if ($this->getArgument('advice')) {
$argv[] = '--advice';
}
if ($this->getArgument('apply-patches')) {
$argv[] = '--apply-patches';
}
if ($this->getArgument('never-apply-patches')) {
$argv[] = '--never-apply-patches';
}
$argv = $this->getPassthruArgumentsAsArgv('lint');
if ($repository_api instanceof ArcanistSubversionAPI) {
$argv = array_merge($argv, array_keys($paths));
} else {
@ -905,7 +905,7 @@ EOTEXT
echo "Running unit tests...\n";
try {
$argv = array();
$argv = $this->getPassthruArgumentsAsArgv('unit');
if ($repository_api instanceof ArcanistSubversionAPI) {
$argv = array_merge($argv, array_keys($paths));
}

View file

@ -77,6 +77,7 @@ EOTEXT
$engine = newv($engine_class, array());
$engine->setWorkingCopy($working_copy);
$engine->setPaths($paths);
$engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
$results = $engine->run();