SymfonyCasts / tailwind-bundle

Delightful Tailwind Support for Symfony + AssetMapper
https://symfony.com/bundles/TailwindBundle/current/index.html
MIT License
84 stars 20 forks source link

[CI] Fix randomly failed tests on Windows #74

Closed bocharsky-bw closed 1 month ago

bocharsky-bw commented 1 month ago

Sometimes we have random test failures on Windows, see https://github.com/SymfonyCasts/tailwind-bundle/actions/runs/11490280966/job/31980693499

1) Symfonycasts\TailwindBundle\Tests\TailwindBuilderTest::testBuildProvidedInputFile
Symfony\Component\Filesystem\Exception\IOException: Failed to remove file "D:\a\tailwind-bundle\tailwind-bundle\tests/fixtures/var/tailwind\v3.4.14\tailwindcss-windows-x64.exe": unlink(D:\a\tailwind-bundle\tailwind-bundle\tests/fixtures/var/tailwind\v3.4.14\tailwindcss-windows-x64.exe): Permission denied

D:\a\tailwind-bundle\tailwind-bundle\vendor\symfony\filesystem\Filesystem.php:202
D:\a\tailwind-bundle\tailwind-bundle\vendor\symfony\filesystem\Filesystem.php:190
D:\a\tailwind-bundle\tailwind-bundle\vendor\symfony\filesystem\Filesystem.php:190
D:\a\tailwind-bundle\tailwind-bundle\vendor\symfony\filesystem\Filesystem.php:158
D:\a\tailwind-bundle\tailwind-bundle\tests\TailwindBuilderTest.php:24
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestResult.php:[72](https://github.com/SymfonyCasts/tailwind-bundle/actions/runs/11490280966/job/31980693499#step:5:73)8
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:653

Probably this will help? Thoughts?

I think this may help

bocharsky-bw commented 1 month ago

Well, seems it helped, see the prove in https://github.com/SymfonyCasts/tailwind-bundle/actions/runs/11500343719/job/32010355575?pr=74

1) Symfonycasts\TailwindBundle\Tests\TailwindBuilderTest::testBuildProvidedInputFile
Could not remove the temporary tailwind/ dir from the time: Failed to remove file "D:\a\tailwind-bundle\tailwind-bundle\tests/fixtures/var/tailwind\v3.4.14\tailwindcss-windows-x64.exe": unlink(D:\a\tailwind-bundle\tailwind-bundle\tests/fixtures/var/tailwind\v3.4.14\tailwindcss-windows-x64.exe): Permission denied

D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestResult.php:728
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\Framework\TestSuite.php:684
D:\a\tailwind-bundle\tailwind-bundle\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:653

WARNINGS!
Tests: 7, Assertions: 19, Warnings: 1.

@MolloKhan what do you think?

MolloKhan commented 1 month ago

If the file paths with mixed slashes / \ are not the issue, I'd try to remove the tailwind folder in the teardown method instead of setup(), so everything will happen during the same test. I mean, the folder will be created and deleted during the lifecycle of each test. That may help with permissions but I'm guessing

bocharsky-bw commented 1 month ago

@MolloKhan I created a competitor PR for that in #75, let's see

bocharsky-bw commented 1 month ago

Close in favor of #75