facile-it / paraunit

Run PHPUnit tests in parallel
https://engineering.facile.it/paraunit/
Apache License 2.0
133 stars 14 forks source link

Exception with symfony/phpunit-bridge 7.1 #248

Closed garak closed 1 month ago

garak commented 1 month ago

Symfony released version 7.1 today, so I upgraded a project of mine ( the project uses Symfony 6.4, and Symfony 7 for the bridge only).

Tests are broken with the following exception. Downgrading to Symfony 7.0 makes them working again:

1) Bootstrapping of extension Paraunit\Configuration\ParaunitExtension failed: Cannot find TestCase object on call stack
#0 /my_project/vendor/phpunit/phpunit/src/Runner/ErrorHandler.php(87): PHPUnit\Event\Code\TestMethodBuilder::fromCallStack()
#1 /my_project/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php(372): PHPUnit\Runner\ErrorHandler->__invoke(2, 'mkdir(): File e...', '/my_project...', 55)
#2 /my_project/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php(132): Symfony\Bridge\PhpUnit\DeprecationErrorHandler::Symfony\Bridge\PhpUnit\{closure}(2, 'mkdir(): File e...', '/my_project...', 55, Array)
#3 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(2, 'mkdir(): File e...', '/my_project...', 55)
#4 /my_project/vendor/facile-it/paraunit/src/Logs/TestHook/AbstractTestHook.php(55): mkdir('/dev/shm/paraun...', 511, true)
#5 /my_project/vendor/facile-it/paraunit/src/Logs/TestHook/AbstractTestHook.php(26): Paraunit\Logs\TestHook\AbstractTestHook->getLogFilename()
#6 /my_project/vendor/facile-it/paraunit/src/Configuration/ParaunitExtension.php(38): Paraunit\Logs\TestHook\AbstractTestHook->__construct()
#7 /my_project/vendor/phpunit/phpunit/src/Runner/Extension/ExtensionBootstrapper.php(70): Paraunit\Configuration\ParaunitExtension->bootstrap(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\Extension\Facade), Object(PHPUnit\Runner\Extension\ParameterCollection))
#8 /my_project/vendor/phpunit/phpunit/src/TextUI/Application.php(370): PHPUnit\Runner\Extension\ExtensionBootstrapper->bootstrap('Paraunit\\Config...', Array)
#9 /my_project/vendor/phpunit/phpunit/src/TextUI/Application.php(137): PHPUnit\TextUI\Application->bootstrapExtensions(Object(PHPUnit\TextUI\Configuration\Configuration))
#10 /my_project/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)
#11 {main}
Jean85 commented 1 month ago

I'm not sure this is an issue with Paraunit: the trigger is in our extension, but the stack trace shows that the issue is with mkdir, which is triggering a silenced error when the dir already exist, then afterwards PHPUnit's error handler is trying to find a test case which is not there.

It should probably be fixed either in PHPUnit or the Symfony error handler, which is probably interfering with PHPUnit's.

garak commented 1 month ago

The point is that with the bridge 7.1 (and the same version of PHPUnit), tests run fine when I don't use paraunit. I have the exception only when I do use paraunit.

garak commented 1 month ago

Oh, and now things start to become funny: if I upgrade the other symfony components from 6.4.7 to 6.4.8 I get the same exception in paraunit (but, again simple phpunit works). If I downgrade them back to 6.4.7, it works 😕

garak commented 1 month ago

I better isolated the problem and found that symfony/phpunit-bridge 7.0.8 gives the same exception.

Maybe the culprit is the change made in this PR https://github.com/symfony/symfony/pull/54797

Jean85 commented 1 month ago

That's not the proper culprit, just the trigger. IMHO the issue is in the PHPUnit error handler, that thinks that it's invoked always inside a test. I'll try to create a reproducer.

[EDIT] I cannot reproduce. I think you should report this to Symfony.

Jean85 commented 1 month ago

I've tried to reproduce this to report to Symfony, but I noticed that I could simply fix it. #250 is now released as 2.3.3