From bd345c3b4367e566444dc61abcb71f4eddc6aaf4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 10 Aug 2013 02:43:40 +0200 Subject: [PATCH] Add IO to proc executor in a few more places to get more debug info out --- src/Composer/Downloader/ZipDownloader.php | 2 +- src/Composer/Factory.php | 2 +- src/Composer/Package/Locker.php | 14 ++++++++------ src/Composer/Repository/Vcs/VcsDriver.php | 2 +- src/Composer/Script/EventDispatcher.php | 2 +- tests/Composer/Test/InstallerTest.php | 2 +- tests/Composer/Test/Package/LockerTest.php | 15 ++++++++------- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index cef985348..80bc60272 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -27,7 +27,7 @@ class ZipDownloader extends ArchiveDownloader public function __construct(IOInterface $io, Config $config, Cache $cache = null, ProcessExecutor $process = null) { - $this->process = $process ?: new ProcessExecutor; + $this->process = $process ?: new ProcessExecutor($io); parent::__construct($io, $config, $cache); } diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index c8e854e3e..a099abcd0 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -267,7 +267,7 @@ class Factory $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4).'lock' : $composerFile . '.lock'; - $locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, $im, md5_file($composerFile)); + $locker = new Package\Locker($io, new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, $im, md5_file($composerFile)); $composer->setLocker($locker); } diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index de5b1f9bd..a77bbd4e7 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -22,6 +22,7 @@ use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Version\VersionParser; use Composer\Util\Git as GitUtil; +use Composer\IO\IOInterface; /** * Reads/writes project lockfile (composer.lock). @@ -37,24 +38,27 @@ class Locker private $hash; private $loader; private $dumper; + private $process; private $lockDataCache; /** * Initializes packages locker. * + * @param IOInterface $io * @param JsonFile $lockFile lockfile loader * @param RepositoryManager $repositoryManager repository manager instance * @param InstallationManager $installationManager installation manager instance * @param string $hash unique hash of the current composer configuration */ - public function __construct(JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, $hash) + public function __construct(IOInterface $io, JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, $hash) { - $this->lockFile = $lockFile; + $this->lockFile = $lockFile; $this->repositoryManager = $repositoryManager; $this->installationManager = $installationManager; $this->hash = $hash; $this->loader = new ArrayLoader(); $this->dumper = new ArrayDumper(); + $this->process = new ProcessExecutor($io); } /** @@ -321,20 +325,18 @@ class Locker if ($path && in_array($sourceType, array('git', 'hg'))) { $sourceRef = $package->getSourceReference() ?: $package->getDistReference(); - $process = new ProcessExecutor(); - switch ($sourceType) { case 'git': $util = new GitUtil; $util->cleanEnv(); - if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) { + if (0 === $this->process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) { $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); } break; case 'hg': - if (0 === $process->execute('hg log --template "{date|hgdate}" -r '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) { + if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) { $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC')); } break; diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index 31b858089..f6d428802 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -56,7 +56,7 @@ abstract class VcsDriver implements VcsDriverInterface $this->repoConfig = $repoConfig; $this->io = $io; $this->config = $config; - $this->process = $process ?: new ProcessExecutor; + $this->process = $process ?: new ProcessExecutor($io); $this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io); } diff --git a/src/Composer/Script/EventDispatcher.php b/src/Composer/Script/EventDispatcher.php index 47a9cf54a..46d3d94d7 100644 --- a/src/Composer/Script/EventDispatcher.php +++ b/src/Composer/Script/EventDispatcher.php @@ -47,7 +47,7 @@ class EventDispatcher { $this->composer = $composer; $this->io = $io; - $this->process = $process ?: new ProcessExecutor(); + $this->process = $process ?: new ProcessExecutor($io); } /** diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 228283bef..7c3791791 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -186,7 +186,7 @@ class InstallerTest extends TestCase })); } - $locker = new Locker($lockJsonMock, $repositoryManager, $composer->getInstallationManager(), md5(json_encode($composerConfig))); + $locker = new Locker($io, $lockJsonMock, $repositoryManager, $composer->getInstallationManager(), md5(json_encode($composerConfig))); $composer->setLocker($locker); $eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock(); diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index b911d3de9..1b879f421 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -13,13 +13,14 @@ namespace Composer\Test\Package; use Composer\Package\Locker; +use Composer\IO\NullIO; class LockerTest extends \PHPUnit_Framework_TestCase { public function testIsLocked() { $json = $this->createJsonFileMock(); - $locker = new Locker($json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), 'md5'); + $locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), 'md5'); $json ->expects($this->any()) @@ -39,7 +40,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $json ->expects($this->once()) @@ -57,7 +58,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $json ->expects($this->once()) @@ -84,7 +85,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $package1 = $this->createPackageMock(); $package2 = $this->createPackageMock(); @@ -142,7 +143,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $package1 = $this->createPackageMock(); $package1 @@ -161,7 +162,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $json ->expects($this->once()) @@ -177,7 +178,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker($json, $repo, $inst, 'md5'); + $locker = new Locker(new NullIO, $json, $repo, $inst, 'md5'); $json ->expects($this->once())