Browse Source

Fix phar build test

Jordi Boggiano 10 years ago
parent
commit
414cf70008
1 changed files with 17 additions and 4 deletions
  1. 17 4
      tests/Composer/Test/AllFunctionalTest.php

+ 17 - 4
tests/Composer/Test/AllFunctionalTest.php

@@ -65,12 +65,25 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
             $this->markTestSkipped('Building the phar does not work on HHVM.');
         }
 
+        $target = dirname(self::$pharPath);
         $fs = new Filesystem;
-        $fs->removeDirectory(dirname(self::$pharPath));
-        $fs->ensureDirectoryExists(dirname(self::$pharPath));
-        chdir(dirname(self::$pharPath));
+        $fs->removeDirectory($target);
+        $fs->ensureDirectoryExists($target);
+        chdir($target);
+
+        $it = new \RecursiveDirectoryIterator(__DIR__.'/../../../', \RecursiveDirectoryIterator::SKIP_DOTS);
+        $ri = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);
+
+        foreach ($ri as $file) {
+            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
+            if ($file->isDir()) {
+                $fs->ensureDirectoryExists($targetPath);
+            } else {
+                copy($file->getPathname(), $targetPath);
+            }
+        }
 
-        $proc = new Process('php '.escapeshellarg(__DIR__.'/../../../bin/compile'), dirname(self::$pharPath));
+        $proc = new Process('php '.escapeshellarg('./bin/compile'), $target);
         $exitcode = $proc->run();
         if ($exitcode !== 0 || trim($proc->getOutput())) {
             $this->fail($proc->getOutput());