mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 18:22:41 +01:00
Fixup lint testing for changes in D6798
Summary: We have some linters that trigger based on the path name in the tree (some rules apply in some dirs and not others). The changes in D6798 caused all the paths to appear to be outside the tree, so allow for passing a fake through from those test cases that are sensitive to this. We also have a test for the copyright linter, and that needs to read settings from the .arcconfig file. The change to faking a working copy meant that this config option was effectively unset, so add a way to pass the entire arcconfig through from the tests that need it. Lastly, the logic to skip deleted files needs to be special cased when we're faking paths like this: if we've added data for a file in the testable engine, we should also consider that file as existing. Test Plan: `arc unit --everything` here, and passing our tests in our repo over there. Reviewers: epriestley, mareksapota Reviewed By: epriestley CC: Korvin, aran Differential Revision: https://secure.phabricator.com/D6841
This commit is contained in:
parent
2c5c9815c0
commit
4a3d829223
2 changed files with 20 additions and 5 deletions
|
@ -20,6 +20,13 @@ final class UnitTestableArcanistLintEngine extends ArcanistLintEngine {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pathExists($path) {
|
||||||
|
if (idx($this->fileData, $path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return parent::pathExists($path);
|
||||||
|
}
|
||||||
|
|
||||||
protected function buildLinters() {
|
protected function buildLinters() {
|
||||||
return $this->linters;
|
return $this->linters;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,10 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
||||||
PhutilTypeSpec::checkMap(
|
PhutilTypeSpec::checkMap(
|
||||||
$config,
|
$config,
|
||||||
array(
|
array(
|
||||||
'project' => 'optional string',
|
|
||||||
'hook' => 'optional bool',
|
'hook' => 'optional bool',
|
||||||
'config' => 'optional wild',
|
'config' => 'optional wild',
|
||||||
|
'path' => 'optional string',
|
||||||
|
'arcconfig' => 'optional map<string, string>',
|
||||||
));
|
));
|
||||||
|
|
||||||
$exception = null;
|
$exception = null;
|
||||||
|
@ -60,9 +61,15 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
||||||
|
|
||||||
$dir = dirname($full_path);
|
$dir = dirname($full_path);
|
||||||
$path = basename($full_path);
|
$path = basename($full_path);
|
||||||
|
$config_file = null;
|
||||||
|
$arcconfig = idx($config, 'arcconfig');
|
||||||
|
if ($arcconfig) {
|
||||||
|
$config_file = json_encode($arcconfig);
|
||||||
|
}
|
||||||
|
|
||||||
$working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile(
|
$working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile(
|
||||||
$dir,
|
$dir,
|
||||||
null,
|
$config_file,
|
||||||
'Unit Test');
|
'Unit Test');
|
||||||
|
|
||||||
$engine = new UnitTestableArcanistLintEngine();
|
$engine = new UnitTestableArcanistLintEngine();
|
||||||
|
@ -71,12 +78,13 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
||||||
|
|
||||||
$engine->setCommitHookMode(idx($config, 'hook', false));
|
$engine->setCommitHookMode(idx($config, 'hook', false));
|
||||||
|
|
||||||
$linter->addPath($path);
|
$path_name = idx($config, 'path', $path);
|
||||||
$linter->addData($path, $data);
|
$linter->addPath($path_name);
|
||||||
|
$linter->addData($path_name, $data);
|
||||||
$linter->setConfig(idx($config, 'config', array()));
|
$linter->setConfig(idx($config, 'config', array()));
|
||||||
|
|
||||||
$engine->addLinter($linter);
|
$engine->addLinter($linter);
|
||||||
$engine->addFileData($path, $data);
|
$engine->addFileData($path_name, $data);
|
||||||
|
|
||||||
$results = $engine->run();
|
$results = $engine->run();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue