Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Fix randomly failed tests on Windows v2 #75

Merged
merged 12 commits into from
Oct 31, 2024
16 changes: 13 additions & 3 deletions tests/TailwindBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfonycasts\TailwindBundle\TailwindBuilder;
Expand All @@ -20,9 +21,6 @@ class TailwindBuilderTest extends TestCase
protected function setUp(): void
{
$fs = new Filesystem();
if (file_exists(__DIR__.'/fixtures/var/tailwind')) {
$fs->remove(__DIR__.'/fixtures/var/tailwind');
}
$fs->mkdir(__DIR__.'/fixtures/var/tailwind');
}

Expand All @@ -33,6 +31,18 @@ protected function tearDown(): void
foreach ($finder as $file) {
unlink($file->getRealPath());
}
$fs = new Filesystem();
if (file_exists(__DIR__.'/fixtures/var/tailwind')) {
kbond marked this conversation as resolved.
Show resolved Hide resolved
try {
$fs->remove(__DIR__.'/fixtures/var/tailwind');
} catch (IOException $e) {
// Sometimes "Permission denied" error happens on Windows,
// add a warning about it and try again in a second
$this->addWarning('Could not remove the temporary tailwind/ dir (trying again in 1 second): '.$e->getMessage());
sleep(1);
$fs->remove(__DIR__.'/fixtures/var/tailwind');
}
}
}

public function testIntegrationWithDefaultOptions(): void
Expand Down
Loading