From: Eric Stern Date: Mon, 26 Aug 2013 16:59:51 +0000 (-0700) Subject: Add support for 'phpunit_binary' config setting X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a28d4ff3e451714258e49481d7bfaf97ad36ccbe;p=arcanist.git Add support for 'phpunit_binary' config setting 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 --- diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php index a4f05c38..d207d82f 100644 --- a/src/unit/engine/PhpunitTestEngine.php +++ b/src/unit/engine/PhpunitTestEngine.php @@ -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); + } + } } }