]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add support for 'phpunit_binary' config setting
authorEric Stern <eric@wepay.com>
Mon, 26 Aug 2013 16:59:51 +0000 (09:59 -0700)
committerepriestley <git@epriestley.com>
Mon, 26 Aug 2013 16:59:51 +0000 (09:59 -0700)
Summary:
If present, this will override the default phpunit path. Allows easy
integration of Composer-provided installs of phpunit (ex. set phpunit_binary to
vendor/bin/phpunit). If the path provided doesn't resolve to an executable it
will assume the path is relative to the project root.

fix line length issue

Test Plan:
Added phpunit_binary to .arcconfig in a simple project using Composer with
phpunit/phpunit package as part of require-dev (installed to
$ROOT/vendor/bin/phpunit). Phpunit not otherwise installed on the system. Set
unit.engine to PhpunitTestEngine. Confirmed that 'arc unit' used the specified
binary, both at project root and from subdirectories.

Reviewers: epriestley

CC: aurelijus, Korvin, aran
Differential Revision: https://secure.phabricator.com/D6791

src/unit/engine/PhpunitTestEngine.php

index a4f05c38bb2b89e061a38df6a19b6896fe75a335..d207d82f05a47e01a4de831630a8bc192ae37f41 100644 (file)
@@ -14,6 +14,7 @@
 final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine {
 
   private $configFile;
+  private $phpunitBinary = 'phpunit';
   private $affectedTests;
   private $projectRoot;
 
@@ -70,8 +71,8 @@ final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine {
 
       $config = $this->configFile ? csprintf('-c %s', $this->configFile) : null;
 
-      $futures[$test_path] = new ExecFuture('phpunit %C --log-json %s %C %s',
-        $config, $json_tmp, $clover, $test_path);
+      $futures[$test_path] = new ExecFuture('%C %C --log-json %s %C %s',
+        $this->phpunitBinary, $config, $json_tmp, $clover, $test_path);
       $tmpfiles[$test_path] = array(
         'json' => $json_tmp,
         'clover' => $clover_tmp,
@@ -265,5 +266,13 @@ final class PhpunitTestEngine extends ArcanistBaseUnitTestEngine {
           'found in ' . $project_root . $config);
       }
     }
+    if ($bin = $this->getWorkingCopy()->getConfig('unit.phpunit.binary')) {
+      if (Filesystem::binaryExists($bin)) {
+        $this->phpunitBinary = $bin;
+      }
+      else {
+        $this->phpunitBinary = Filesystem::resolvePath($bin, $project_root);
+      }
+    }
   }
 }