1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Prevent failure in end-to-end test from affecting others

This commit is contained in:
Matthew Brown 2019-06-25 20:38:44 -04:00
parent 904267638f
commit 0da801fee1

View File

@ -21,9 +21,6 @@ class PsalmEndToEndTest extends TestCase
/** @var string */ /** @var string */
private $psalter = __DIR__ . '/../../psalter'; private $psalter = __DIR__ . '/../../psalter';
/** @var string */
private static $previousWorkingDir;
/** @var string */ /** @var string */
private static $tmpDir; private static $tmpDir;
@ -37,19 +34,16 @@ class PsalmEndToEndTest extends TestCase
if (! is_string($getcwd)) { if (! is_string($getcwd)) {
throw new \Exception('Couldn\'t get working directory'); throw new \Exception('Couldn\'t get working directory');
} }
self::$previousWorkingDir = $getcwd;
chdir(self::$tmpDir);
mkdir('src'); mkdir(self::$tmpDir . '/src');
copy(__DIR__ . '/../fixtures/DummyProjectWithErrors/composer.json', 'composer.json'); copy(__DIR__ . '/../fixtures/DummyProjectWithErrors/composer.json', self::$tmpDir . '/composer.json');
(new Process(['composer', 'install']))->mustRun(); (new Process(['composer', 'install'], self::$tmpDir))->mustRun();
} }
public static function tearDownAfterClass(): void public static function tearDownAfterClass(): void
{ {
chdir(self::$previousWorkingDir);
self::recursiveRemoveDirectory(self::$tmpDir); self::recursiveRemoveDirectory(self::$tmpDir);
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
@ -112,7 +106,7 @@ class PsalmEndToEndTest extends TestCase
*/ */
private function runPsalm(array $args, bool $shouldFail = false): array private function runPsalm(array $args, bool $shouldFail = false): array
{ {
$process = new Process(array_merge([$this->psalm], $args)); $process = new Process(array_merge([$this->psalm], $args), self::$tmpDir);
if (! $shouldFail) { if (! $shouldFail) {
$process->mustRun(); $process->mustRun();