From 47c52ad60225877fa92f394a7f4d9213974ad12f Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:28:32 +0100 Subject: [PATCH] fix /src/psalm.xml not removed between tests and remove psalm.xml at the end of tests --- tests/EndToEnd/PsalmEndToEndTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/EndToEnd/PsalmEndToEndTest.php b/tests/EndToEnd/PsalmEndToEndTest.php index b02660cec..bdbb2cb1a 100644 --- a/tests/EndToEnd/PsalmEndToEndTest.php +++ b/tests/EndToEnd/PsalmEndToEndTest.php @@ -24,6 +24,8 @@ use function sys_get_temp_dir; use function tempnam; use function unlink; +use const DIRECTORY_SEPARATOR; + /** * Tests some of the most important use cases of the psalm and psalter commands, by launching a new * process as if invoked by a real user. @@ -47,8 +49,6 @@ class PsalmEndToEndTest extends TestCase throw new Exception('Couldn\'t get working directory'); } - mkdir(self::$tmpDir . '/src'); - copy(__DIR__ . '/../fixtures/DummyProjectWithErrors/composer.json', self::$tmpDir . '/composer.json'); $process = new Process(['composer', 'install', '--no-plugins'], self::$tmpDir, null, null, 120); @@ -63,7 +63,8 @@ class PsalmEndToEndTest extends TestCase public function setUp(): void { - @unlink(self::$tmpDir . '/psalm.xml'); + mkdir(self::$tmpDir . '/src'); + copy( __DIR__ . '/../fixtures/DummyProjectWithErrors/src/FileWithErrors.php', self::$tmpDir . '/src/FileWithErrors.php', @@ -73,9 +74,16 @@ class PsalmEndToEndTest extends TestCase public function tearDown(): void { + @unlink(self::$tmpDir . '/psalm.xml'); + if (file_exists(self::$tmpDir . '/cache')) { self::recursiveRemoveDirectory(self::$tmpDir . '/cache'); } + + if (file_exists(self::$tmpDir . '/src')) { + self::recursiveRemoveDirectory(self::$tmpDir . '/src'); + } + parent::tearDown(); } @@ -275,7 +283,7 @@ class PsalmEndToEndTest extends TestCase $dir = opendir($src); while (false !== ($file = readdir($dir))) { if (($file !== '.') && ($file !== '..')) { - $full = $src . '/' . $file; + $full = $src . DIRECTORY_SEPARATOR . $file; if (is_dir($full)) { self::recursiveRemoveDirectory($full); } else {