Skip to content

Commit fc54a48

Browse files
committedApr 2, 2013
Fix archiver tests on windows
1 parent 6401b6a commit fc54a48

File tree

6 files changed

+16
-26
lines changed

6 files changed

+16
-26
lines changed
 

‎src/Composer/Package/Archiver/ArchivableFilesFinder.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Composer\Package\BasePackage;
1616
use Composer\Package\PackageInterface;
17+
use Composer\Util\Filesystem;
1718

1819
use Symfony\Component\Finder;
1920

@@ -40,7 +41,9 @@ class ArchivableFilesFinder extends \FilterIterator
4041
*/
4142
public function __construct($sources, array $excludes)
4243
{
43-
$sources = realpath($sources);
44+
$fs = new Filesystem();
45+
46+
$sources = $fs->normalizePath($sources);
4447

4548
$filters = array(
4649
new HgExcludeFilter($sources),
@@ -51,11 +54,11 @@ public function __construct($sources, array $excludes)
5154
$this->finder = new Finder\Finder();
5255
$this->finder
5356
->in($sources)
54-
->filter(function (\SplFileInfo $file) use ($sources, $filters) {
57+
->filter(function (\SplFileInfo $file) use ($sources, $filters, $fs) {
5558
$relativePath = preg_replace(
5659
'#^'.preg_quote($sources, '#').'#',
5760
'',
58-
str_replace(DIRECTORY_SEPARATOR, '/', $file->getRealPath())
61+
$fs->normalizePath($file->getRealPath())
5962
);
6063

6164
$exclude = false;

‎tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
use Symfony\Component\Process\Process;
1919

20-
/**
21-
* @author Nils Adermann <naderman@naderman.de>
22-
*/
2320
class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
2421
{
2522
protected $sources;
2623
protected $finder;
24+
protected $fs;
2725

28-
protected function setup()
26+
protected function setUp()
2927
{
3028
$fs = new Filesystem;
29+
$this->fs = $fs;
3130

32-
$this->sources = realpath(sys_get_temp_dir()).
33-
'/composer_archiver_test'.uniqid(mt_rand(), true);
31+
$this->sources = $fs->normalizePath(
32+
realpath(sys_get_temp_dir()).'/composer_archiver_test'.uniqid(mt_rand(), true)
33+
);
3434

3535
$fileTree = array(
3636
'A/prefixA.foo',
@@ -171,7 +171,7 @@ protected function getArchivableFiles()
171171
$files = array();
172172
foreach ($this->finder as $file) {
173173
if (!$file->isDir()) {
174-
$files[] = preg_replace('#^'.preg_quote($this->sources, '#').'#', '', $file->getRealPath());
174+
$files[] = preg_replace('#^'.preg_quote($this->sources, '#').'#', '', $this->fs->normalizePath($file->getRealPath()));
175175
}
176176
}
177177

@@ -190,10 +190,12 @@ protected function getArchivedFiles($command)
190190

191191
$files = array();
192192
foreach ($iterator as $file) {
193-
$files[] = preg_replace('#^phar://'.preg_quote($this->sources, '#').'/archive\.zip/archive#', '', $file);
193+
$files[] = preg_replace('#^phar://'.preg_quote($this->sources, '#').'/archive\.zip/archive#', '', $this->fs->normalizePath($file));
194194
}
195195

196+
unset($archive, $iterator, $file);
196197
unlink($this->sources.'/archive.zip');
198+
197199
return $files;
198200
}
199201

‎tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
use Composer\Package\Archiver\ArchiveManager;
1919
use Composer\Package\PackageInterface;
2020

21-
/**
22-
* @author Till Klampaeckel <till@php.net>
23-
* @author Matthieu Moquet <matthieu@moquet.net>
24-
*/
2521
class ArchiveManagerTest extends ArchiverTest
2622
{
2723
protected $manager;

‎tests/Composer/Test/Package/Archiver/ArchiverTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
use Composer\Util\ProcessExecutor;
1717
use Composer\Package\Package;
1818

19-
/**
20-
* @author Till Klampaeckel <till@php.net>
21-
* @author Matthieu Moquet <matthieu@moquet.net>
22-
*/
2319
abstract class ArchiverTest extends \PHPUnit_Framework_TestCase
2420
{
2521
/**

‎tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
use Composer\Package\Archiver\HgExcludeFilter;
1616

17-
/**
18-
* @author Nils Adermann <naderman@naderman.de>
19-
*/
2017
class HgExcludeFilterTest extends \PHPUnit_Framework_TestCase
2118
{
2219
/**

‎tests/Composer/Test/Package/Archiver/PharArchiverTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
use Composer\Package\Archiver\PharArchiver;
1616

17-
/**
18-
* @author Till Klampaeckel <till@php.net>
19-
* @author Matthieu Moquet <matthieu@moquet.net>
20-
*/
2117
class PharArchiverTest extends ArchiverTest
2218
{
2319
public function testTarArchive()

0 commit comments

Comments
 (0)
Please sign in to comment.