Add IO to proc executor in a few more places to get more debug info out
parent
029341e114
commit
bd345c3b43
|
@ -27,7 +27,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
|
|
||||||
public function __construct(IOInterface $io, Config $config, Cache $cache = null, ProcessExecutor $process = null)
|
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);
|
parent::__construct($io, $config, $cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ class Factory
|
||||||
$lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
|
$lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
|
||||||
? substr($composerFile, 0, -4).'lock'
|
? substr($composerFile, 0, -4).'lock'
|
||||||
: $composerFile . '.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);
|
$composer->setLocker($locker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use Composer\Package\Dumper\ArrayDumper;
|
||||||
use Composer\Package\Loader\ArrayLoader;
|
use Composer\Package\Loader\ArrayLoader;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
use Composer\Util\Git as GitUtil;
|
use Composer\Util\Git as GitUtil;
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads/writes project lockfile (composer.lock).
|
* Reads/writes project lockfile (composer.lock).
|
||||||
|
@ -37,24 +38,27 @@ class Locker
|
||||||
private $hash;
|
private $hash;
|
||||||
private $loader;
|
private $loader;
|
||||||
private $dumper;
|
private $dumper;
|
||||||
|
private $process;
|
||||||
private $lockDataCache;
|
private $lockDataCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes packages locker.
|
* Initializes packages locker.
|
||||||
*
|
*
|
||||||
|
* @param IOInterface $io
|
||||||
* @param JsonFile $lockFile lockfile loader
|
* @param JsonFile $lockFile lockfile loader
|
||||||
* @param RepositoryManager $repositoryManager repository manager instance
|
* @param RepositoryManager $repositoryManager repository manager instance
|
||||||
* @param InstallationManager $installationManager installation manager instance
|
* @param InstallationManager $installationManager installation manager instance
|
||||||
* @param string $hash unique hash of the current composer configuration
|
* @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->repositoryManager = $repositoryManager;
|
||||||
$this->installationManager = $installationManager;
|
$this->installationManager = $installationManager;
|
||||||
$this->hash = $hash;
|
$this->hash = $hash;
|
||||||
$this->loader = new ArrayLoader();
|
$this->loader = new ArrayLoader();
|
||||||
$this->dumper = new ArrayDumper();
|
$this->dumper = new ArrayDumper();
|
||||||
|
$this->process = new ProcessExecutor($io);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,20 +325,18 @@ class Locker
|
||||||
|
|
||||||
if ($path && in_array($sourceType, array('git', 'hg'))) {
|
if ($path && in_array($sourceType, array('git', 'hg'))) {
|
||||||
$sourceRef = $package->getSourceReference() ?: $package->getDistReference();
|
$sourceRef = $package->getSourceReference() ?: $package->getDistReference();
|
||||||
$process = new ProcessExecutor();
|
|
||||||
|
|
||||||
switch ($sourceType) {
|
switch ($sourceType) {
|
||||||
case 'git':
|
case 'git':
|
||||||
$util = new GitUtil;
|
$util = new GitUtil;
|
||||||
$util->cleanEnv();
|
$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'));
|
$datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'hg':
|
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'));
|
$datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,7 +56,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
||||||
$this->repoConfig = $repoConfig;
|
$this->repoConfig = $repoConfig;
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->process = $process ?: new ProcessExecutor;
|
$this->process = $process ?: new ProcessExecutor($io);
|
||||||
$this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io);
|
$this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class EventDispatcher
|
||||||
{
|
{
|
||||||
$this->composer = $composer;
|
$this->composer = $composer;
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->process = $process ?: new ProcessExecutor();
|
$this->process = $process ?: new ProcessExecutor($io);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
$composer->setLocker($locker);
|
||||||
|
|
||||||
$eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock();
|
$eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock();
|
||||||
|
|
|
@ -13,13 +13,14 @@
|
||||||
namespace Composer\Test\Package;
|
namespace Composer\Test\Package;
|
||||||
|
|
||||||
use Composer\Package\Locker;
|
use Composer\Package\Locker;
|
||||||
|
use Composer\IO\NullIO;
|
||||||
|
|
||||||
class LockerTest extends \PHPUnit_Framework_TestCase
|
class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testIsLocked()
|
public function testIsLocked()
|
||||||
{
|
{
|
||||||
$json = $this->createJsonFileMock();
|
$json = $this->createJsonFileMock();
|
||||||
$locker = new Locker($json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), 'md5');
|
$locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), 'md5');
|
||||||
|
|
||||||
$json
|
$json
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
|
@ -39,7 +40,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$json
|
$json
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -57,7 +58,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$json
|
$json
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -84,7 +85,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$package1 = $this->createPackageMock();
|
$package1 = $this->createPackageMock();
|
||||||
$package2 = $this->createPackageMock();
|
$package2 = $this->createPackageMock();
|
||||||
|
@ -142,7 +143,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$package1 = $this->createPackageMock();
|
$package1 = $this->createPackageMock();
|
||||||
$package1
|
$package1
|
||||||
|
@ -161,7 +162,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$json
|
$json
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -177,7 +178,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
||||||
$repo = $this->createRepositoryManagerMock();
|
$repo = $this->createRepositoryManagerMock();
|
||||||
$inst = $this->createInstallationManagerMock();
|
$inst = $this->createInstallationManagerMock();
|
||||||
|
|
||||||
$locker = new Locker($json, $repo, $inst, 'md5');
|
$locker = new Locker(new NullIO, $json, $repo, $inst, 'md5');
|
||||||
|
|
||||||
$json
|
$json
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
|
Loading…
Reference in New Issue