mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-24 22:40:55 +01:00
Fix ArcanistLinterTestCase
Summary: We could also inject the value from the test case config but this is simpler. Test Plan: $ arc unit src/lint/linter/ArcanistLicenseLinter.php Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2035 Differential Revision: https://secure.phabricator.com/D3895
This commit is contained in:
parent
21530fa459
commit
0938091a99
10 changed files with 30 additions and 2 deletions
|
@ -35,8 +35,11 @@ abstract class ArcanistLicenseLinter extends ArcanistLinter {
|
||||||
abstract protected function getLicensePatterns();
|
abstract protected function getLicensePatterns();
|
||||||
|
|
||||||
public function lintPath($path) {
|
public function lintPath($path) {
|
||||||
|
$copyright_holder = $this->getConfig('copyright_holder');
|
||||||
|
if ($copyright_holder === null) {
|
||||||
$working_copy = $this->getEngine()->getWorkingCopy();
|
$working_copy = $this->getEngine()->getWorkingCopy();
|
||||||
$copyright_holder = $working_copy->getConfig('copyright_holder');
|
$copyright_holder = $working_copy->getConfig('copyright_holder');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$copyright_holder) {
|
if (!$copyright_holder) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,12 +17,22 @@ abstract class ArcanistLinter {
|
||||||
protected $stopAllLinters = false;
|
protected $stopAllLinters = false;
|
||||||
|
|
||||||
private $customSeverityMap = array();
|
private $customSeverityMap = array();
|
||||||
|
private $config = array();
|
||||||
|
|
||||||
public function setCustomSeverityMap(array $map) {
|
public function setCustomSeverityMap(array $map) {
|
||||||
$this->customSeverityMap = $map;
|
$this->customSeverityMap = $map;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setConfig(array $config) {
|
||||||
|
$this->config = $config;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getConfig($key, $default = null) {
|
||||||
|
return idx($this->config, $key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
public function getActivePath() {
|
public function getActivePath() {
|
||||||
return $this->activePath;
|
return $this->activePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ abstract class ArcanistLinterTestCase extends ArcanistTestCase {
|
||||||
|
|
||||||
$linter->addPath($path);
|
$linter->addPath($path);
|
||||||
$linter->addData($path, $data);
|
$linter->addData($path, $data);
|
||||||
|
$linter->setConfig(idx($config, 'config', array()));
|
||||||
|
|
||||||
$engine->addLinter($linter);
|
$engine->addLinter($linter);
|
||||||
$engine->addFileData($path, $data);
|
$engine->addFileData($path, $data);
|
||||||
|
|
|
@ -27,3 +27,5 @@ error:1:1
|
||||||
int main(int argv, char **argv) {
|
int main(int argv, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -35,3 +35,5 @@ function Copyright(Copyright $copyright) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* More Comments */
|
/* More Comments */
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -23,3 +23,5 @@ error:1:1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do_stuff();
|
do_stuff();
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -25,3 +25,5 @@ error:1:1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do_stuff();
|
do_stuff();
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -27,3 +27,5 @@ error:1:1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do_stuff();
|
do_stuff();
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -25,3 +25,5 @@ error:1:1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do_stuff();
|
do_stuff();
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
|
@ -25,3 +25,5 @@ error:1:1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do_stuff();
|
do_stuff();
|
||||||
|
~~~~~~~~~~
|
||||||
|
{"config": {"copyright_holder": "Facebook, Inc."}}
|
||||||
|
|
Loading…
Reference in a new issue