]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add unit tests for `ArcanistFilenameLinter`
authorJoshua Spence <josh@joshuaspence.com>
Mon, 12 Jan 2015 19:42:09 +0000 (06:42 +1100)
committerJoshua Spence <josh@joshuaspence.com>
Mon, 12 Jan 2015 19:47:19 +0000 (06:47 +1100)
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

src/__phutil_library_map__.php
src/lint/engine/ArcanistUnitTestableLintEngine.php
src/lint/linter/__tests__/ArcanistFilenameLinterTestCase.php [new file with mode: 0644]
src/lint/linter/__tests__/ArcanistLinterTestCase.php
src/lint/linter/__tests__/filename/bad_filename.lint-test [new file with mode: 0644]
src/lint/linter/__tests__/filename/good_filename.lint-test [new file with mode: 0644]

index e7c44504427417f33e2498270d01cb195e8abdd3..f75c0a5a55532abd6fddd27b2c04d65b39a5a413 100644 (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',
index af30a1043e77b4203dbc825752bce7b83181f9f5..08393944b34695c4ab5f9695ca7e270ceed5a0a1 100644 (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);
diff --git a/src/lint/linter/__tests__/ArcanistFilenameLinterTestCase.php b/src/lint/linter/__tests__/ArcanistFilenameLinterTestCase.php
new file mode 100644 (file)
index 0000000..7b43988
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+final class ArcanistFilenameLinterTestCase
+  extends ArcanistArcanistLinterTestCase {
+
+  public function testLinter() {
+    $this->executeTestsInDirectory(dirname(__FILE__).'/filename/');
+  }
+
+}
index 3b019f218449accaa749b31cfde986ca1a3c805a..4de8005c7a0818603dc48e7f5a1005dec163e5d6 100644 (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));
     }
diff --git a/src/lint/linter/__tests__/filename/bad_filename.lint-test b/src/lint/linter/__tests__/filename/bad_filename.lint-test
new file mode 100644 (file)
index 0000000..7eb7c74
--- /dev/null
@@ -0,0 +1,5 @@
+~~~~~~~~~~
+error::
+~~~~~~~~~~
+~~~~~~~~~~
+{"path": "bad@filename"}
diff --git a/src/lint/linter/__tests__/filename/good_filename.lint-test b/src/lint/linter/__tests__/filename/good_filename.lint-test
new file mode 100644 (file)
index 0000000..ceedd46
--- /dev/null
@@ -0,0 +1,4 @@
+~~~~~~~~~~
+~~~~~~~~~~
+~~~~~~~~~~
+{"path": "good_filename"}