浏览代码

Merge remote-tracking branch 'RobLoach/versioncontrolnotfound'

Jordi Boggiano 12 年之前
父节点
当前提交
91db9d920b
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php

+ 25 - 0
tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php

@@ -101,6 +101,11 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
 
     public function testGitExcludes()
     {
+        // Ensure that git is available for testing.
+        if (!$this->getProcessAvailable('git')) {
+            return $this->markTestSkipped('git is not available.');
+        }
+
         file_put_contents($this->sources.'/.gitignore', implode("\n", array(
             '# gitignore rules with comments and blank lines',
             '',
@@ -140,6 +145,10 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
 
     public function testHgExcludes()
     {
+        // Ensure that Mercurial is available for testing.
+        if (!$this->getProcessAvailable('hg')) {
+            return $this->markTestSkipped('Mercurial is not available.');
+        }
         file_put_contents($this->sources.'/.hgignore', implode("\n", array(
             '# hgignore rules with comments, blank lines and syntax changes',
             '',
@@ -206,4 +215,20 @@ class ArchivableFilesFinderTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals($expectedFiles, $actualFiles);
     }
+
+    /**
+     * Check whether or not the given process is available.
+     *
+     * @param string $process The name of the binary to test.
+     *
+     * @return boolean True if the process is available, false otherwise.
+     */
+    protected function getProcessAvailable($process)
+    {
+        // Check if the command is found. The 127 exit code is returned when the
+        // command is not found.
+        $process = new Process($process);
+
+        return $process->run() !== 127;
+    }
 }