]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add unit tests for `ArcanistMergeConflictLinter`.
authorJoshua Spence <josh@joshuaspence.com>
Thu, 19 Jun 2014 21:59:12 +0000 (07:59 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Thu, 19 Jun 2014 21:59:12 +0000 (07:59 +1000)
Summary: Self explanatory. Also fixed the character offset to start at 1 instead of 0 (because the other linters seem to do this).

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9626

src/__phutil_library_map__.php
src/lint/linter/ArcanistMergeConflictLinter.php
src/lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php [new file with mode: 0644]
src/lint/linter/__tests__/mergeconflict/mergeconflict.lint-test [new file with mode: 0644]

index 1b1b4b41f9fb306fd456a719ea0a3b153b72f94f..1b325c6c2f6516d0cdfd136bcfe777898b8c4bed 100644 (file)
@@ -122,6 +122,7 @@ phutil_register_library_map(array(
     'ArcanistMercurialParser' => 'repository/parser/ArcanistMercurialParser.php',
     'ArcanistMercurialParserTestCase' => 'repository/parser/__tests__/ArcanistMercurialParserTestCase.php',
     'ArcanistMergeConflictLinter' => 'lint/linter/ArcanistMergeConflictLinter.php',
+    'ArcanistMergeConflictLinterTestCase' => 'lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php',
     'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php',
     'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php',
     'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php',
@@ -294,6 +295,7 @@ phutil_register_library_map(array(
     'ArcanistMercurialAPI' => 'ArcanistRepositoryAPI',
     'ArcanistMercurialParserTestCase' => 'ArcanistTestCase',
     'ArcanistMergeConflictLinter' => 'ArcanistLinter',
+    'ArcanistMergeConflictLinterTestCase' => 'ArcanistArcanistLinterTestCase',
     'ArcanistNoEffectException' => 'ArcanistUsageException',
     'ArcanistNoEngineException' => 'ArcanistUsageException',
     'ArcanistNoLintLinter' => 'ArcanistLinter',
index 8144bd1889db9eb82f7fc4767668d1e2a1e2f88a..f7092ff6e2ec6e2620664218733ed166b9b42ed3 100644 (file)
@@ -38,7 +38,7 @@ final class ArcanistMergeConflictLinter extends ArcanistLinter {
       if (preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
         $this->raiseLintAtLine(
           $lineno + 1,
-          0,
+          1,
           self::LINT_MERGECONFLICT,
           pht('This syntax indicates there is an unresolved merge conflict.'));
       }
diff --git a/src/lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php b/src/lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php
new file mode 100644 (file)
index 0000000..beed019
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+final class ArcanistMergeConflictLinterTestCase
+  extends ArcanistArcanistLinterTestCase {
+
+  public function testMergeConflictLint() {
+    $this->executeTestsInDirectory(
+      dirname(__FILE__).'/mergeconflict/',
+      new ArcanistMergeConflictLinter());
+  }
+
+}
diff --git a/src/lint/linter/__tests__/mergeconflict/mergeconflict.lint-test b/src/lint/linter/__tests__/mergeconflict/mergeconflict.lint-test
new file mode 100644 (file)
index 0000000..3e30be5
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "foo": "bar",
+<<<<<<< HEAD
+    "bar": "baz"
+=======
+    "baz": "foo"
+>>>>>>> branch2
+}
+~~~~~~~~~~
+error:5:1