1
0
Fork 0

Fix for tests when Mercurial or git are not available

pull/1829/head
Rob Loach 2013-04-25 14:57:58 -04:00
parent 8c197d2325
commit 692c63cdd2
1 changed files with 25 additions and 0 deletions

View File

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