Fix archiver tests on windows
parent
6401b6aa46
commit
fc54a48b52
|
@ -14,6 +14,7 @@ namespace Composer\Package\Archiver;
|
|||
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Util\Filesystem;
|
||||
|
||||
use Symfony\Component\Finder;
|
||||
|
||||
|
@ -40,7 +41,9 @@ class ArchivableFilesFinder extends \FilterIterator
|
|||
*/
|
||||
public function __construct($sources, array $excludes)
|
||||
{
|
||||
$sources = realpath($sources);
|
||||
$fs = new Filesystem();
|
||||
|
||||
$sources = $fs->normalizePath($sources);
|
||||
|
||||
$filters = array(
|
||||
new HgExcludeFilter($sources),
|
||||
|
@ -51,11 +54,11 @@ class ArchivableFilesFinder extends \FilterIterator
|
|||
$this->finder = new Finder\Finder();
|
||||
$this->finder
|
||||
->in($sources)
|
||||
->filter(function (\SplFileInfo $file) use ($sources, $filters) {
|
||||
->filter(function (\SplFileInfo $file) use ($sources, $filters, $fs) {
|
||||
$relativePath = preg_replace(
|
||||
'#^'.preg_quote($sources, '#').'#',
|
||||
'',
|
||||
str_replace(DIRECTORY_SEPARATOR, '/', $file->getRealPath())
|
||||
$fs->normalizePath($file->getRealPath())
|
||||
);
|
||||
|
||||
$exclude = false;
|
||||
|
|
|
@ -17,20 +17,20 @@ use Composer\Util\Filesystem;
|
|||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $sources;
|
||||
protected $finder;
|
||||
protected $fs;
|
||||
|
||||
protected function setup()
|
||||
protected function setUp()
|
||||
{
|
||||
$fs = new Filesystem;
|
||||
$this->fs = $fs;
|
||||
|
||||
$this->sources = realpath(sys_get_temp_dir()).
|
||||
'/composer_archiver_test'.uniqid(mt_rand(), true);
|
||||
$this->sources = $fs->normalizePath(
|
||||
realpath(sys_get_temp_dir()).'/composer_archiver_test'.uniqid(mt_rand(), true)
|
||||
);
|
||||
|
||||
$fileTree = array(
|
||||
'A/prefixA.foo',
|
||||
|
@ -171,7 +171,7 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
|||
$files = array();
|
||||
foreach ($this->finder as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$files[] = preg_replace('#^'.preg_quote($this->sources, '#').'#', '', $file->getRealPath());
|
||||
$files[] = preg_replace('#^'.preg_quote($this->sources, '#').'#', '', $this->fs->normalizePath($file->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,10 +190,12 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$files = array();
|
||||
foreach ($iterator as $file) {
|
||||
$files[] = preg_replace('#^phar://'.preg_quote($this->sources, '#').'/archive\.zip/archive#', '', $file);
|
||||
$files[] = preg_replace('#^phar://'.preg_quote($this->sources, '#').'/archive\.zip/archive#', '', $this->fs->normalizePath($file));
|
||||
}
|
||||
|
||||
unset($archive, $iterator, $file);
|
||||
unlink($this->sources.'/archive.zip');
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@ use Composer\Package\Archiver;
|
|||
use Composer\Package\Archiver\ArchiveManager;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @author Till Klampaeckel <till@php.net>
|
||||
* @author Matthieu Moquet <matthieu@moquet.net>
|
||||
*/
|
||||
class ArchiveManagerTest extends ArchiverTest
|
||||
{
|
||||
protected $manager;
|
||||
|
|
|
@ -16,10 +16,6 @@ use Composer\Util\Filesystem;
|
|||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Package\Package;
|
||||
|
||||
/**
|
||||
* @author Till Klampaeckel <till@php.net>
|
||||
* @author Matthieu Moquet <matthieu@moquet.net>
|
||||
*/
|
||||
abstract class ArchiverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,6 @@ namespace Composer\Test\Package\Archiver;
|
|||
|
||||
use Composer\Package\Archiver\HgExcludeFilter;
|
||||
|
||||
/**
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class HgExcludeFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace Composer\Test\Package\Archiver;
|
|||
|
||||
use Composer\Package\Archiver\PharArchiver;
|
||||
|
||||
/**
|
||||
* @author Till Klampaeckel <till@php.net>
|
||||
* @author Matthieu Moquet <matthieu@moquet.net>
|
||||
*/
|
||||
class PharArchiverTest extends ArchiverTest
|
||||
{
|
||||
public function testTarArchive()
|
||||
|
|
Loading…
Reference in New Issue