]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix ArcanistLinterTestCase
authorvrana <jakubv@fb.com>
Mon, 5 Nov 2012 23:58:24 +0000 (15:58 -0800)
committervrana <jakubv@fb.com>
Tue, 6 Nov 2012 00:36:01 +0000 (16:36 -0800)
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

src/lint/linter/ArcanistLicenseLinter.php
src/lint/linter/ArcanistLinter.php
src/lint/linter/__tests__/ArcanistLinterTestCase.php
src/lint/linter/__tests__/apachelicense/c-basic.lint-test
src/lint/linter/__tests__/apachelicense/greedy.lint-test
src/lint/linter/__tests__/apachelicense/php-basic.lint-test
src/lint/linter/__tests__/apachelicense/php-script.lint-test
src/lint/linter/__tests__/apachelicense/php-update-mess.lint-test
src/lint/linter/__tests__/apachelicense/php-update-multi.lint-test
src/lint/linter/__tests__/apachelicense/php-update-single.lint-test

index 024c88fa5c04d0cc957986366f1a0ea616b3c105..03401f639610faee99a00ca76b2e5325b05e4c70 100644 (file)
@@ -35,8 +35,11 @@ abstract class ArcanistLicenseLinter extends ArcanistLinter {
   abstract protected function getLicensePatterns();
 
   public function lintPath($path) {
-    $working_copy = $this->getEngine()->getWorkingCopy();
-    $copyright_holder = $working_copy->getConfig('copyright_holder');
+    $copyright_holder = $this->getConfig('copyright_holder');
+    if ($copyright_holder === null) {
+      $working_copy = $this->getEngine()->getWorkingCopy();
+      $copyright_holder = $working_copy->getConfig('copyright_holder');
+    }
 
     if (!$copyright_holder) {
       return;
index cf3da352e232bd95c1ad4815bcefe611af92ea22..2b5dd53b9d738bc904fc206727669631ec2ac4ae 100644 (file)
@@ -17,12 +17,22 @@ abstract class ArcanistLinter {
   protected $stopAllLinters = false;
 
   private $customSeverityMap = array();
+  private $config = array();
 
   public function setCustomSeverityMap(array $map) {
     $this->customSeverityMap = $map;
     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() {
     return $this->activePath;
   }
index 364e65f8c47c357c3b471e7a88dee1b3875f4acd..2873fb509ab4a1ec82379ff7795009f75642c141 100644 (file)
@@ -68,6 +68,7 @@ abstract class ArcanistLinterTestCase extends ArcanistTestCase {
 
       $linter->addPath($path);
       $linter->addData($path, $data);
+      $linter->setConfig(idx($config, 'config', array()));
 
       $engine->addLinter($linter);
       $engine->addFileData($path, $data);
index 1c49d4ae2a50bea3dd6c0f8b8e26b6729b723a61..109eeb62f4ed8801e16f87df54053e94634b6679 100644 (file)
@@ -27,3 +27,5 @@ error:1:1
 int main(int argv, char **argv) {
   return 0;
 }
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index e111c0bdf28d4d62ecc4a23e9d744d62323e92c9..33a8a6a7a0987993d1286259ed824ec51c593993 100644 (file)
@@ -35,3 +35,5 @@ function Copyright(Copyright $copyright) {
 }
 
 /* More Comments */
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index 1b43f13c26e6c947ce3899406f97bd79b96e997a..72d75e3b4d05f124fbe76b3bddcb4e6682f27cbe 100644 (file)
@@ -23,3 +23,5 @@ error:1:1
  */
 
 do_stuff();
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index 36254ec4d15fa714a488bb1d6e7020d6aebb92df..9cce53e022115b0ee507af81ee24c6690d97cd6f 100644 (file)
@@ -25,3 +25,5 @@ error:1:1
  */
 
 do_stuff();
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index a4d306bf119a9eec0f13cfd8bb115f80f1499a3c..286f0dc99305726fa6c99fb67bfd6f1bd620ec6c 100644 (file)
@@ -27,3 +27,5 @@ error:1:1
  */
 
 do_stuff();
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index 4fb90031e80c77c79b6a03e8e1a40e1a1c907029..6a54847e817e99577226fd415499f351189b0f96 100644 (file)
@@ -25,3 +25,5 @@ error:1:1
  */
 
 do_stuff();
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}
index 4fb90031e80c77c79b6a03e8e1a40e1a1c907029..6a54847e817e99577226fd415499f351189b0f96 100644 (file)
@@ -25,3 +25,5 @@ error:1:1
  */
 
 do_stuff();
+~~~~~~~~~~
+{"config": {"copyright_holder": "Facebook, Inc."}}