mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-23 13:08:17 +01:00
Allow skipping unit tests and support 'repeat' workflow arguments
Summary: We run all tests before deploy but some of them are expected to fail. We need to skip them. It can be useful also for someone else. I don't propagate this to `arc diff` as that would be much more complicated - we would need a new state 'partially skipped'. The 'path' argument needs to be a file, skipping whole dirs is not supported. The 'path' argument is in fact engine specific and engines can support format like 'Class::testMethod' but I didn't bother to document it to not confuse people. Test Plan: `arc unit --skip test.php` `arc unit --skip ../src/test.php` Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2673
This commit is contained in:
parent
6aa621ebee
commit
6433f7ff3d
4 changed files with 38 additions and 6 deletions
|
@ -25,6 +25,7 @@ abstract class ArcanistBaseUnitTestEngine {
|
||||||
|
|
||||||
private $workingCopy;
|
private $workingCopy;
|
||||||
private $paths;
|
private $paths;
|
||||||
|
private $skipFiles;
|
||||||
private $arguments = array();
|
private $arguments = array();
|
||||||
protected $diffID;
|
protected $diffID;
|
||||||
private $enableAsyncTests;
|
private $enableAsyncTests;
|
||||||
|
@ -54,6 +55,15 @@ abstract class ArcanistBaseUnitTestEngine {
|
||||||
return $this->paths;
|
return $this->paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function setSkipFiles(array $paths) {
|
||||||
|
$this->skipFiles = $paths;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getSkipFiles() {
|
||||||
|
return $this->skipFiles;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setArguments(array $arguments) {
|
final public function setArguments(array $arguments) {
|
||||||
$this->arguments = $arguments;
|
$this->arguments = $arguments;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -77,6 +77,13 @@ final class PhutilUnitTestEngine extends ArcanistBaseUnitTestEngine {
|
||||||
} while ($library_path != '.');
|
} while ($library_path != '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$skip = array();
|
||||||
|
foreach ($this->getSkipFiles() as $skip_path) {
|
||||||
|
$skip_path = Filesystem::resolvePath($skip_path);
|
||||||
|
$skip_path = Filesystem::readablePath($skip_path, $library_root);
|
||||||
|
$skip[$skip_path] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Look for any class that extends ArcanistPhutilTestCase inside a
|
// Look for any class that extends ArcanistPhutilTestCase inside a
|
||||||
// __tests__ directory in any parent directory of every affected file.
|
// __tests__ directory in any parent directory of every affected file.
|
||||||
//
|
//
|
||||||
|
@ -100,6 +107,9 @@ final class PhutilUnitTestEngine extends ArcanistBaseUnitTestEngine {
|
||||||
->selectAndLoadSymbols();
|
->selectAndLoadSymbols();
|
||||||
|
|
||||||
foreach ($symbols as $symbol) {
|
foreach ($symbols as $symbol) {
|
||||||
|
if (isset($skip[$symbol['where']])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$run_tests[$symbol['name']] = true;
|
$run_tests[$symbol['name']] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,11 +532,7 @@ abstract class ArcanistBaseWorkflow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArgument($key, $default = null) {
|
public function getArgument($key, $default = null) {
|
||||||
$args = $this->arguments;
|
return idx($this->arguments, $key, $default);
|
||||||
if (!array_key_exists($key, $args)) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $args[$key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getCompleteArgumentSpecification() {
|
final public function getCompleteArgumentSpecification() {
|
||||||
|
@ -567,6 +563,12 @@ abstract class ArcanistBaseWorkflow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($spec as $long => $options) {
|
||||||
|
if (!empty($options['repeat'])) {
|
||||||
|
$dict[$long] = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$more = array();
|
$more = array();
|
||||||
for ($ii = 0; $ii < count($args); $ii++) {
|
for ($ii = 0; $ii < count($args); $ii++) {
|
||||||
$arg = $args[$ii];
|
$arg = $args[$ii];
|
||||||
|
@ -603,7 +605,11 @@ abstract class ArcanistBaseWorkflow {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
"Option '{$arg}' requires a parameter.");
|
"Option '{$arg}' requires a parameter.");
|
||||||
}
|
}
|
||||||
$dict[$arg_key] = $args[$ii + 1];
|
if (!empty($options['repeat'])) {
|
||||||
|
$dict[$arg_key][] = $args[$ii + 1];
|
||||||
|
} else {
|
||||||
|
$dict[$arg_key] = $args[$ii + 1];
|
||||||
|
}
|
||||||
$ii++;
|
$ii++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,11 @@ EOTEXT
|
||||||
'help' =>
|
'help' =>
|
||||||
"Override configured unit engine for this project."
|
"Override configured unit engine for this project."
|
||||||
),
|
),
|
||||||
|
'skip' => array(
|
||||||
|
'param' => 'path',
|
||||||
|
'help' => "Specify file paths that will be ignored.",
|
||||||
|
'repeat' => true,
|
||||||
|
),
|
||||||
'coverage' => array(
|
'coverage' => array(
|
||||||
'help' => 'Always enable coverage information.',
|
'help' => 'Always enable coverage information.',
|
||||||
'conflicts' => array(
|
'conflicts' => array(
|
||||||
|
@ -127,6 +132,7 @@ EOTEXT
|
||||||
$this->engine = newv($engine_class, array());
|
$this->engine = newv($engine_class, array());
|
||||||
$this->engine->setWorkingCopy($working_copy);
|
$this->engine->setWorkingCopy($working_copy);
|
||||||
$this->engine->setPaths($paths);
|
$this->engine->setPaths($paths);
|
||||||
|
$this->engine->setSkipFiles($this->getArgument('skip'));
|
||||||
$this->engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
|
$this->engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
|
||||||
|
|
||||||
$enable_coverage = null; // Means "default".
|
$enable_coverage = null; // Means "default".
|
||||||
|
|
Loading…
Add table
Reference in a new issue