From d54675551ebde3ca13c48b47def95049e01cea3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandr=20=C5=A0t=C5=A1epelin?= Date: Thu, 23 Apr 2026 13:24:29 +0300 Subject: [PATCH] fix: bootstrap `` before sealing the event facade in `--parallel` mode --- .../Parallel/Paratest/WrapperRunner.php | 3 -- tests/.snapshots/success.txt | 5 +++- .../ParallelRunnerWarning/PassingTest.php | 3 ++ .../SubscribingExtension.php | 25 ++++++++++++++++ .../ParallelRunnerWarning/bootstrap.php | 6 ++++ .../.tests/ParallelRunnerWarning/phpunit.xml | 16 ++++++++++ tests/Visual/ParallelRunnerWarning.php | 30 +++++++++++++++++++ 7 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 tests/.tests/ParallelRunnerWarning/PassingTest.php create mode 100644 tests/.tests/ParallelRunnerWarning/SubscribingExtension.php create mode 100644 tests/.tests/ParallelRunnerWarning/bootstrap.php create mode 100644 tests/.tests/ParallelRunnerWarning/phpunit.xml create mode 100644 tests/Visual/ParallelRunnerWarning.php diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 331b0c7dc..192197cd8 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -16,7 +16,6 @@ use ParaTest\WrapperRunner\WrapperWorker; use Pest\Result; use Pest\TestSuite; -use PHPUnit\Event\Facade as EventFacade; use PHPUnit\Event\Test\AfterLastTestMethodFailed; use PHPUnit\Event\TestRunner\WarningTriggered; use PHPUnit\Runner\CodeCoverage; @@ -148,8 +147,6 @@ public function run(): int $directory = dirname(__DIR__); assert($directory !== ''); ExcludeList::addDirectory($directory); - TestResultFacade::init(); - EventFacade::instance()->seal(); $suiteLoader = new SuiteLoader( $this->options, $this->output, diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 58dbeddf4..5c66a8a35 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1909,6 +1909,9 @@ PASS Tests\Visual\ParallelNestedDatasets ✓ parallel loads nested datasets from nested directories + PASS Tests\Visual\ParallelRunnerWarning + ✓ parallel bootstraps extensions that register subscribers the same way sequential does + PASS Tests\Visual\SingleTestOrDirectory ✓ allows to run a single test ✓ allows to run a directory @@ -1938,4 +1941,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1329 passed (3010 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1330 passed (3015 assertions) \ No newline at end of file diff --git a/tests/.tests/ParallelRunnerWarning/PassingTest.php b/tests/.tests/ParallelRunnerWarning/PassingTest.php new file mode 100644 index 000000000..915336ab3 --- /dev/null +++ b/tests/.tests/ParallelRunnerWarning/PassingTest.php @@ -0,0 +1,3 @@ +assertTrue(true); diff --git a/tests/.tests/ParallelRunnerWarning/SubscribingExtension.php b/tests/.tests/ParallelRunnerWarning/SubscribingExtension.php new file mode 100644 index 000000000..4b0396086 --- /dev/null +++ b/tests/.tests/ParallelRunnerWarning/SubscribingExtension.php @@ -0,0 +1,25 @@ +registerSubscriber(new class implements PreparedSubscriber { + public function notify(Prepared $event): void + { + } + }); + } +} diff --git a/tests/.tests/ParallelRunnerWarning/bootstrap.php b/tests/.tests/ParallelRunnerWarning/bootstrap.php new file mode 100644 index 000000000..12468e82b --- /dev/null +++ b/tests/.tests/ParallelRunnerWarning/bootstrap.php @@ -0,0 +1,6 @@ + + + + + . + + + + + + diff --git a/tests/Visual/ParallelRunnerWarning.php b/tests/Visual/ParallelRunnerWarning.php new file mode 100644 index 000000000..a95bfe3ea --- /dev/null +++ b/tests/Visual/ParallelRunnerWarning.php @@ -0,0 +1,30 @@ + 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'], + ); + + $process->run(); + + return [ + 'output' => removeAnsiEscapeSequences($process->getOutput()), + 'exitCode' => $process->getExitCode(), + ]; +}; + +test('parallel bootstraps extensions that register subscribers the same way sequential does', function () use ($run) { + $result = $run('-c', 'tests/.tests/ParallelRunnerWarning/phpunit.xml'); + + expect($result['output']) + ->toContain('2 passed') + ->toContain('Parallel: 2 processes') + ->not->toContain('warning') + ->not->toContain('Bootstrapping of extension'); + + expect($result['exitCode'])->toBe(0); +})->skipOnWindows();