1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +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 $workingCopy;
private $paths; private $paths;
private $arguments = array();
final public function __construct() { final public function __construct() {
@ -45,6 +46,15 @@ abstract class ArcanistBaseUnitTestEngine {
return $this->paths; 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(); abstract public function run();
} }

View file

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

View file

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

View file

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