private $workingCopy;
private $paths;
+ private $arguments = array();
final public function __construct() {
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();
}
+phutil_require_module('phutil', 'utils');
+
phutil_require_source('ArcanistBaseUnitTestEngine.php');
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;
+ }
+
}
'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' =>
'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',
);
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 {
echo "Running unit tests...\n";
try {
- $argv = array();
+ $argv = $this->getPassthruArgumentsAsArgv('unit');
if ($repository_api instanceof ArcanistSubversionAPI) {
$argv = array_merge($argv, array_keys($paths));
}
$engine = newv($engine_class, array());
$engine->setWorkingCopy($working_copy);
$engine->setPaths($paths);
+ $engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
$results = $engine->run();