mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Add unit tests for ArcanistFilenameLinter
Summary: Self-explanatory. Test Plan: `arc unit` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11341
This commit is contained in:
parent
c86c1ff6f2
commit
f58642a8ab
6 changed files with 28 additions and 4 deletions
|
@ -74,6 +74,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistExternalLinterTestCase' => 'lint/linter/__tests__/ArcanistExternalLinterTestCase.php',
|
||||
'ArcanistFeatureWorkflow' => 'workflow/ArcanistFeatureWorkflow.php',
|
||||
'ArcanistFilenameLinter' => 'lint/linter/ArcanistFilenameLinter.php',
|
||||
'ArcanistFilenameLinterTestCase' => 'lint/linter/__tests__/ArcanistFilenameLinterTestCase.php',
|
||||
'ArcanistFlagWorkflow' => 'workflow/ArcanistFlagWorkflow.php',
|
||||
'ArcanistFlake8Linter' => 'lint/linter/ArcanistFlake8Linter.php',
|
||||
'ArcanistFlake8LinterTestCase' => 'lint/linter/__tests__/ArcanistFlake8LinterTestCase.php',
|
||||
|
@ -269,6 +270,7 @@ phutil_register_library_map(array(
|
|||
'ArcanistExternalLinterTestCase' => 'ArcanistLinterTestCase',
|
||||
'ArcanistFeatureWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistFilenameLinter' => 'ArcanistLinter',
|
||||
'ArcanistFilenameLinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
||||
'ArcanistFlagWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistFlake8Linter' => 'ArcanistExternalLinter',
|
||||
'ArcanistFlake8LinterTestCase' => 'ArcanistExternalLinterTestCase',
|
||||
|
|
|
@ -19,7 +19,7 @@ final class ArcanistUnitTestableLintEngine extends ArcanistLintEngine {
|
|||
}
|
||||
|
||||
public function pathExists($path) {
|
||||
if (idx($this->fileData, $path)) {
|
||||
if (idx($this->fileData, $path) !== null) {
|
||||
return true;
|
||||
}
|
||||
return parent::pathExists($path);
|
||||
|
|
10
src/lint/linter/__tests__/ArcanistFilenameLinterTestCase.php
Normal file
10
src/lint/linter/__tests__/ArcanistFilenameLinterTestCase.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistFilenameLinterTestCase
|
||||
extends ArcanistArcanistLinterTestCase {
|
||||
|
||||
public function testLinter() {
|
||||
$this->executeTestsInDirectory(dirname(__FILE__).'/filename/');
|
||||
}
|
||||
|
||||
}
|
|
@ -207,15 +207,18 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
|
|||
implode("\n", $raised));
|
||||
|
||||
foreach (array_diff_key($expect, $seen) as $missing => $ignored) {
|
||||
list($sev, $line, $char) = explode(':', $missing);
|
||||
$missing = explode(':', $missing);
|
||||
$sev = array_shift($missing);
|
||||
$pos = $missing;
|
||||
|
||||
$this->assertFailure(
|
||||
pht(
|
||||
"In '%s', expected lint to raise %s on line %d at char %d, ".
|
||||
"but no %s was raised. %s",
|
||||
$file,
|
||||
$sev,
|
||||
$line,
|
||||
$char,
|
||||
idx($pos, 0),
|
||||
idx($pos, 1),
|
||||
$sev,
|
||||
$raised));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
~~~~~~~~~~
|
||||
error::
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"path": "bad@filename"}
|
|
@ -0,0 +1,4 @@
|
|||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"path": "good_filename"}
|
Loading…
Reference in a new issue