Browse Source

Fix archiver tests on windows

Jordi Boggiano 12 years ago
parent
commit
fc54a48b52

+ 6 - 3
src/Composer/Package/Archiver/ArchivableFilesFinder.php

@@ -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;

+ 10 - 8
tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php

@@ -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;
     }
 

+ 0 - 4
tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php

@@ -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;

+ 0 - 4
tests/Composer/Test/Package/Archiver/ArchiverTest.php

@@ -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
 {
     /**

+ 0 - 3
tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php

@@ -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
 {
     /**

+ 0 - 4
tests/Composer/Test/Package/Archiver/PharArchiverTest.php

@@ -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()