1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +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:
Joshua Spence 2015-01-13 06:42:09 +11:00
parent c86c1ff6f2
commit f58642a8ab
6 changed files with 28 additions and 4 deletions

View file

@ -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',

View file

@ -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);

View file

@ -0,0 +1,10 @@
<?php
final class ArcanistFilenameLinterTestCase
extends ArcanistArcanistLinterTestCase {
public function testLinter() {
$this->executeTestsInDirectory(dirname(__FILE__).'/filename/');
}
}

View file

@ -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));
}

View file

@ -0,0 +1,5 @@
~~~~~~~~~~
error::
~~~~~~~~~~
~~~~~~~~~~
{"path": "bad@filename"}

View file

@ -0,0 +1,4 @@
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
{"path": "good_filename"}