mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-03-24 05:10:29 +01:00
Randomize temp-dir and ignore IOException in tests
If the file pointer is not closed or some other program (like TGitcache.exe) is reading the file the tests don't fail anymore.
This commit is contained in:
@@ -8,15 +8,13 @@ use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class ClientTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $tmpdir = '/tmp/gitlist';
|
||||
protected static $tmpdir;
|
||||
|
||||
protected $client;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
self::$tmpdir = getenv('TMP').'/gitlist';
|
||||
}
|
||||
self::$tmpdir = str_replace('\\', '/', getenv('TMP') .'/gitlist_' . md5(time() . mt_rand()));
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->mkdir(self::$tmpdir);
|
||||
@@ -58,7 +56,7 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsNotAbleToGetUnexistingRepositories()
|
||||
{
|
||||
$this->client->getRepositories('/tmp');
|
||||
$this->client->getRepositories(self::$tmpdir);
|
||||
}
|
||||
|
||||
public function testIsCreatingRepository()
|
||||
@@ -117,6 +115,11 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
$fs->remove(self::$tmpdir);
|
||||
|
||||
try {
|
||||
//$fs->remove(self::$tmpdir);
|
||||
} catch (IOException $e) {
|
||||
// Ignore, file is not closed yet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user