Browse Source

Add IO to proc executor in a few more places to get more debug info out

Jordi Boggiano 12 years ago
parent
commit
bd345c3b43

+ 1 - 1
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);
     }
 

+ 1 - 1
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);
         }
 

+ 8 - 6
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;

+ 1 - 1
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);
     }
 

+ 1 - 1
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);
     }
 
     /**

+ 1 - 1
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();

+ 8 - 7
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())